|
| | Log (const std::string &className) |
| | Constructor.
|
| |
| virtual | ~Log () |
| | Destructor.
|
| |
| void | debug (const std::string &methodName, Message logMacroMessage) const |
| | Log Debug Information.
|
| |
| void | info (const std::string &methodName, Message logMacroMessage) |
| | Log Information.
|
| |
| void | warning (const std::string &methodName, Message logMacroMessage) |
| | Log a Warning.
|
| |
| void | error (const std::string &methodName, Message logMacroMessage) |
| | Log an Error.
|
| |
| void | traceIn (const std::string &methodName, Message logMacroMessage) |
| |
| void | traceOut (const std::string &methodName, Message logMacroMessage) |
| |
| void | indent (bool indent, const std::string &trace, Message logMacroMessage) const |
| | Indent the Subsequent Messages.
|
| |
| std::string | getTraceInformation (const std::string &methodName) const |
| |
Log Device.
Log is the class all logging classes should use. To use the logging API they have to create an instance by their own. It is suggested to hold this instance static for the constructor of the Log class has to be given the class name of the logging class. The Log class itself is stateless. The log requests on this instance are processed here and forwarded to the assigned logger (an internal attribute).
Which concrete implementation has to be used for logging is switched using a compiler attribute. Since the logging is used extremely often, this is better than dynamic binding.
There are five different log levels, the user may write any output:
- error: Here only errors have to be written to. Error logMacroMessages may never be oppressed.
- warning:
- debug: Debug information that is switched off normally. Only available if you use Debug
- info: Statistical information, copyright and similar information. Should be used rather seldom.
Runtime
The underlying log device (like the CommandlineLogger) has to offer synchronized output methods. Thus, calls to logging methods in multithreaded environments mark synchronization points of your programme and will change timing behaviour!
output format
You can switch the log output format by setting -DUseLogService=xxx. At the moment, I support two different formats for xxx:
- CommandLineLogger This is the default.
- ChromeTraceFileLogger For the Chrome tracing API.
- Author
- Tobias Weinzierl
Definition at line 516 of file Log.h.
We could make the logMacroMessage passed into a log statement a string.
However, many codes write rather complicated strings and therefore spend a lot of time to construct the logMacroMessage. This is fine in release mode, e.g., where the number of strings is small. It is problematic in trace mode or debug, where we have a lot of strings, and most of them won't be used, as we filter them out later anyway.
Therefore, I switch to lazy evaluation: a logMacroMessage string is constructed if and only if the logMacroMessage will be written. The construction is realised through a (lambda) function modelled via Message.
Definition at line 577 of file Log.h.
| void tarch::logging::Log::debug |
( |
const std::string & | methodName, |
|
|
Message | logMacroMessage ) const |
Log Debug Information.
Remark: Please do not use this operation directly, but use the macros above instead.
The method has to be given the method name. Often it is useful to pass the whole method signature, that means e.g. if the method info itself would log, the method invocation would look like this:
info("info(std::string,std::string)", "just an example text");
So you are able to identify methods in your log although you use overloading.
- Parameters
-
| methodName | method name |
| logMacroMessage | log logMacroMessage |
Definition at line 600 of file Log.h.
| void tarch::logging::Log::error |
( |
const std::string & | methodName, |
|
|
Message | logMacroMessage ) |
Log an Error.
The method has to be given the method name. Often it is useful to pass the whole method signature, that means e.g. if the method info itself would log, the method invocation would look like this:
info("info(std::string,std::string)", "just an example text");
So you are able to identify methods in your log although you use overloading.
- Parameters
-
| methodName | method name |
| logMacroMessage | log logMacroMessage |
| void tarch::logging::Log::info |
( |
const std::string & | methodName, |
|
|
Message | logMacroMessage ) |
Log Information.
The method has to be given the method name. Often it is useful to pass the whole method signature, that means e.g. if the method info itself would log, the method invocation would look like this:
info("info(std::string,std::string)", "just an example text");
So you are able to identify methods in your log although you use overloading.
- Parameters
-
| methodName | method name |
| logMacroMessage | log logMacroMessage |
| void tarch::logging::Log::warning |
( |
const std::string & | methodName, |
|
|
Message | logMacroMessage ) |
Log a Warning.
The method has to be given the method name. Often it is useful to pass the whole method signature, that means e.g. if the method info itself would log, the method invocation would look like this:
info("info(std::string,std::string)", "just an example text");
So you are able to identify methods in your log although you use overloading.
- Parameters
-
| methodName | method name |
| logMacroMessage | log logMacroMessage |