📄 readme
字号:
The Log is not instantiated directly but a reference to a Log objectis obtained through a call to one of the static getLog() methods.Each log has 6 builtin LogStreams each of which recieve messages ata different LogLevel. In this way different LogStreams can be turnedon or off at will.The five primary builtin LogStreams are: Log.debug Log.info Log.warn Log.error Log.fatalIn addition to these five the Log object itself is also an LogStream.Usage: In order to use the log the client program sends a message toone of the Log objects LogStream objects.Eg. log("Final statistics follow:"); log.debug("Entering loop:"); log.warn("Value to delete does not exist."); In addition to treating the builtin LogStream objects as methods theycan also be used like traditional C++ streams (which they are).Eg. log << "Vat = " << vatPercent << "%" << std::endl; log.debug << "value = " << value << std::endl; log.error << "This should never happen at line " << __LINE__; log.error << ", file " << __FILE__ << std::endl; log.fatal << "Bad vibes, exiting..." << std::endl; exit(10); Both the above approaches can be mixed. Eg. log("Total annual income = ") << lowIncomeValue << std::endl; log.debug("variable dv = ") << dv << std::endl; On top of all this additional LogStream objects can be added to the Logusing the addLogStream() method. Eg. log.addLogStream("report"); This can be subsequently accessed thus: log.to("report", "Temperature guage initialization."); log.to("report") << "Temperature of core: " << coreTemp << std::endl; Different levels of reporting can be achieved by setting the LogMask ofthe Log. Each LogStream operates at a specific LogLevel and the LogLevelof each of the builtin ones is set such that they may be enabled ordisabled in a hirarchal manner. For example if you wanted to receive only'error' and 'fatal' messages you could set the LogMask thus: log.setLogMask(log.error.getLogLevel()); This sets the LogMask of the Log to a value such that all LogStream objectsoperating below the level of 'error' will be turned off.You may wish your Log to send its output to more than one place. This canbe achieved by adding std::ostream objects to the Log.Eg. // Send the logging over a network. std::ostream* os = socket->get_output(); log.addOStream(*os); This output may subsequently be removed with: log.delOStream(*os);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -