|
cisst-saw
|
Declaration of cmnLogger amd macros for human readable logging. More...
#include <cisstCommon/cmnPortability.h>#include <cisstCommon/cmnLogLoD.h>#include <cisstCommon/cmnLODOutputMultiplexer.h>#include <cisstCommon/cmnMultiplexerStreambuf.h>#include <cisstCommon/cmnLODMultiplexerStreambuf.h>#include <string>#include <vector>#include <fstream>#include <cisstCommon/cmnExport.h>Go to the source code of this file.
Classes | |
| class | cmnLogger |
| Class to glue the class register, the output multiplexer and the message level of detail to form the logging entity of cisst. More... | |
Declaration of cmnLogger amd macros for human readable logging.
| #define _cmnLogger_h |
| #define BYPASS_CMN_LOG |
| #define CMN_LOG | ( | lod | ) |
This macro is used to log human readable information within the scope of a global function (e.g. main()). It can also be used in classes which are not registered in cmnClassRegister (see also macros CMN_DECLARE_SERVICES and CMN_IMPLEMENT_SERVICES declared in cmnClassRegister.h). For a registered class, please use CMN_LOG_CLASS.
The message is streamed along with a Level of Detail to cmnLogger provided that the function and overall log masks allow the level of detail associated to the message. The overall mask can be set using cmnLogger::SetMask. The function mask can be set using cmnLogger::SetMaskFunction.
The macro creates an output stream if the level of detail of the message satisfies the criterion defined above. It can be used as any other output stream:
| lod | The log level of detail of the message. |
| #define CMN_LOG_CLASS | ( | lod | ) |
| #define CMN_LOG_CLASS_INIT_DEBUG CMN_LOG_CLASS(CMN_LOG_LEVEL_INIT_DEBUG) |
| #define CMN_LOG_CLASS_INIT_ERROR CMN_LOG_CLASS(CMN_LOG_LEVEL_INIT_ERROR) << CMN_LOG_DETAILS << " " |
Macros defined to use CMN_LOG_CLASS for a given level of detail.
| #define CMN_LOG_CLASS_INIT_VERBOSE CMN_LOG_CLASS(CMN_LOG_LEVEL_INIT_VERBOSE) |
| #define CMN_LOG_CLASS_INIT_WARNING CMN_LOG_CLASS(CMN_LOG_LEVEL_INIT_WARNING) |
| #define CMN_LOG_CLASS_INSTANCE | ( | objectPointer, | |
| lod ) |
This macro is used to log human readable information within a registered class. It can only be used within the scope of a method part of a class registered in the cmnClassRegister using the macros CMN_DECLARE_SERVICES and CMN_IMPLEMENT_SERVICES declared in cmnClassRegister.h. For a non registered class of a global function, please use CMN_LOG.
The message is streamed along with a Level of Detail to cmnLogger provided that two conditions are met:
The macro creates an output stream if the level of detail of the message satisfies the two criteria defined above. It can be used as any other output stream:
| lod | The log level of detail of the message. |
| #define CMN_LOG_CLASS_INSTANCE_INIT_DEBUG | ( | objectPointer | ) |
| #define CMN_LOG_CLASS_INSTANCE_INIT_ERROR | ( | objectPointer | ) |
Macros defined to use CMN_LOG_CLASS_INSTANCE for a given level of detail.
| #define CMN_LOG_CLASS_INSTANCE_INIT_VERBOSE | ( | objectPointer | ) |
| #define CMN_LOG_CLASS_INSTANCE_INIT_WARNING | ( | objectPointer | ) |
| #define CMN_LOG_CLASS_INSTANCE_RUN_DEBUG | ( | objectPointer | ) |
| #define CMN_LOG_CLASS_INSTANCE_RUN_ERROR | ( | objectPointer | ) |
| #define CMN_LOG_CLASS_INSTANCE_RUN_VERBOSE | ( | objectPointer | ) |
| #define CMN_LOG_CLASS_INSTANCE_RUN_WARNING | ( | objectPointer | ) |
| #define CMN_LOG_CLASS_RUN_DEBUG CMN_LOG_CLASS(CMN_LOG_LEVEL_RUN_DEBUG) |
| #define CMN_LOG_CLASS_RUN_ERROR CMN_LOG_CLASS(CMN_LOG_LEVEL_RUN_ERROR) << CMN_LOG_DETAILS << " " |
| #define CMN_LOG_CLASS_RUN_VERBOSE CMN_LOG_CLASS(CMN_LOG_LEVEL_RUN_VERBOSE) |
| #define CMN_LOG_CLASS_RUN_WARNING CMN_LOG_CLASS(CMN_LOG_LEVEL_RUN_WARNING) |
| #define CMN_LOG_DETAILS "File: " << cmnLogger::ExtractFileName(__FILE__) << " Line: " << __LINE__ << " - " |
This macro is used to add useful information to Log macros (CMN_LOG_CLASS and CMN_LOG). It provides the additional functionality of logging the file name and line number at which the message was generated.
For example:
For any error with a very common message, this helps the programmer to quickly find the origin of the message in the source code.
| #define CMN_LOG_INIT_DEBUG CMN_LOG(CMN_LOG_LEVEL_INIT_DEBUG) |
| #define CMN_LOG_INIT_ERROR CMN_LOG(CMN_LOG_LEVEL_INIT_ERROR) << CMN_LOG_DETAILS << " " |
Macros defined to use CMN_LOG for a given level of detail.
| #define CMN_LOG_INIT_VERBOSE CMN_LOG(CMN_LOG_LEVEL_INIT_VERBOSE) |
| #define CMN_LOG_INIT_WARNING CMN_LOG(CMN_LOG_LEVEL_INIT_WARNING) |
| #define CMN_LOG_RUN_DEBUG CMN_LOG(CMN_LOG_LEVEL_RUN_DEBUG) |
| #define CMN_LOG_RUN_ERROR CMN_LOG(CMN_LOG_LEVEL_RUN_ERROR) << CMN_LOG_DETAILS << " " |
| #define CMN_LOG_RUN_VERBOSE CMN_LOG(CMN_LOG_LEVEL_RUN_VERBOSE) |
| #define CMN_LOG_RUN_WARNING CMN_LOG(CMN_LOG_LEVEL_RUN_WARNING) |