libmove3d-planners
|
This file implements macros to help with the logging, in a way similar to ROS, using log4cxx. More...
#include <log4cxx/logger.h>
#include <iostream>
Go to the source code of this file.
Macros | |
#define | INIT_MOVE3D_LOG(name) log4cxx::LoggerPtr __move3d_logger__ = logm3d::getLogger(name) |
INIT_MOVE3D_LOG macro creates a logger to be used by AutoLogger macros in the scope where it is called. More... | |
#define | MOVE3D_STATIC_LOGGER static log4cxx::LoggerPtr __move3d_logger__ |
MOVE3D_STATIC_LOGGER macro defines a static logger for the class. More... | |
#define | INIT_MOVE3D_STATIC_LOGGER(classname, loggername) log4cxx::LoggerPtr classname::__move3d_logger__ = logm3d::getLogger(loggername) |
INIT_MOVE3D_STATIC_LOGGER() macro is to be called in the class implementation file (.cpp) to instantiate the static logger. More... | |
#define | LOGM3D_TRACE(_logger_, msg) LOG4CXX_TRACE(_logger_,msg) |
The following macros does not need INIT_MOVE3D_LOG to be called, and can be used to have different loggers in a same cpp file. More... | |
#define | LOGM3D_DEBUG(_logger_, msg) LOG4CXX_DEBUG(_logger_,msg) |
#define | LOGM3D_INFO(_logger_, msg) LOG4CXX_INFO(_logger_,msg) |
#define | LOGM3D_WARN(_logger_, msg) LOG4CXX_WARN(_logger_,msg) |
#define | LOGM3D_ERROR(_logger_, msg) LOG4CXX_ERROR(_logger_,msg) |
#define | LOGM3D_FATAL(_logger_, msg) LOG4CXX_FATAL(_logger_,msg) |
#define | M3D_TRACE(msg) LOGM3D_TRACE(__move3d_logger__,msg) |
#define | M3D_DEBUG(msg) LOGM3D_DEBUG(__move3d_logger__,msg) |
Logs a message with the logger defined in the scope with macro of AutoLogger. More... | |
#define | M3D_INFO(msg) LOGM3D_INFO(__move3d_logger__,msg) |
#define | M3D_WARN(msg) LOGM3D_WARN(__move3d_logger__,msg) |
#define | M3D_ERROR(msg) LOGM3D_ERROR(__move3d_logger__,msg) |
#define | M3D_FATAL(msg) LOGM3D_FATAL(__move3d_logger__,msg) |
Typedefs | |
typedef log4cxx::LoggerPtr | logm3d::LoggerPtr |
This file implements macros to help with the logging, in a way similar to ROS, using log4cxx.
The macros defined here have to be called to initialize and then use logging in a class/method/file/function... The macros allow to log for different levels, which are (ordered): TRACE < DEBUG < INFO < WARN < ERROR < FATAL see http://wiki.ros.org/Verbosity%20Levels for information about the purpose of each level
It is possible to select at execution time the lower log level that will be displayed for each logger (in each cpp file) see http://logging.apache.org/log4cxx/usage.html for a short introduction to log4cxx
You can directly use log4cxx API, but here you will find some helpers to make it easier and faster to implement. Also, if for some reason the logging system needs to be changed, using the logm3d interface defined here will help in the changing process.
The logger names have to be choosen wisely. There is a hierarchy of names, so for instance, planners is an ancestor of planners.hrics.mho and the parent of planners.hrics. By default, a logger inherits its parents property, but it can be overriden. So for debugging all HRICS module, one can disable debug infromation for the root (by default, no debug information anywhere) and set planners.hrics logging level to debug, only the debug (and higher) level information will be print.
When naming a logger, you need to keep this in mind, so that an other developer/user can choose to display only what he needs. So do not hesitate to go deep in the hierarchy (e.g. planners.hrics.mho.grid.cell)
The system will look for different file, until finding one, testing in that order:
$LOGM3D_CONFIGURATION
$LOG4CXX_CONFIGURATION
./logm3d.properties
./log4cxx.properties
$HOME_MOVE3D/logm3d.properties
$HOME_MOVE3D/log4cxx.properties
#define LOGM3D_TRACE | ( | _logger_, | |
msg | |||
) | LOG4CXX_TRACE(_logger_,msg) |
The following macros does not need INIT_MOVE3D_LOG to be called, and can be used to have different loggers in a same cpp file.
_logger_ | a logm3d::LoggerPtr to use as logger |
msg | a std::string, char*, wchar*, the insertion operator (<<) can be used (see log4cxx doc) |
These loggers are obtained through the various logm3d::getLogger() and similar functions, (or log4cxx::Logger::getLogger() : to be avoided, create a logm3d logger instead)