|Synopsis:||Logging shall be be performed according to a common standard.|
TTLog is NavKit's configurable logging mechanism. It is enabled by default in debug builds and release builds.
Because TTLog is enabled in release builds, all messages will be part of NavKit library. This means that even debug messages should contain professional, proper English as it is to be expected that they will be read by external parties.
There are two aspects to TTLog: instrumentation of the source code to include logging messages, and configuring what is to be logged during any specific run.
Details of how to instrument your code to include logging are given here.
Details of the configuration file are given in Configuration file.
First you have to define a logger, which is done in the cpp file that contains the module that is to be instrumented. This is done with help of the following macro, which is available in ./Framework/Common/Logging/Interface/TTLog.h:
The next step is to instrument your code with logging statements. This can be done by using the following macro:
A set of macros makes it simple to log directly at the correct level. These are:
LOG() logs at the lowest level and the other macros correspond to other predefined severity levels
If your module is spread over multiple cpp files, you can use the following macro to declare a logger that is defined in another cpp file:
+ variableName is the same as is used in the DEFINE_LOGGER macro.
DECLARE_LOGGER can also be used when you want to log in a module's header file. This should only be done in exceptional cases.
The overall logging system has to be initialized before it can be used (see also Logging before initialization). For NavKit this is done in NavKitMain. If you have other executables with which you want to use TTLog you have to initialize the logging system with the following statements:
NOTE: The LOGT and LOGT_LV macros are deprecated and should no longer be used.
If the logger is not yet initialized, that is, the call to Initialize has not been done, logging will be performed as if there were no configuration file.
This means that even if logging is disabled completely, there can still be some logging to the console in the event that the logger is used before initialization. This logging will stop as soon as Initialize is executed, assuming the configuration file disables logging.
Each message is assigned a level: the smaller the number the more severe the event being reported. These values can be used with the loglevel attribute to set the level of logging.
Where a message indicates an error, it should almost always end up in a log file unless logging is disabled for the module. If a message is a debug message for a certain module, probably only the team that maintains that module is interested in that message and therefore it severity should be much lower.
The following severity levels are defined:
|TomTom Guidelines Logging Guidelines|