class mrpt::system::COutputLogger

Versatile class for consistent logging and management of output messages.

COutputLogger is a versatile class for logging messages either to the terminal window or to an external file. Class instances can take messages in std::string using the logStr class methods. The following macros are also provided for usage within a class that inherits from COutputLogger :

// Plain strings:
MRPT_LOG_DEBUG("This will be shown only if verbosity level is LVL_DEBUG.");
MRPT_LOG_ERROR("This message will be always shown.");
// printf-like versions:
MRPT_LOG_ERROR_FMT("Out of range value: %i.", int_param);
// stream-like versions:
MRPT_LOG_ERROR_STREAM("Out of range value: " << int_param << " more vars: "
<< other_var);
// Minimum period (in seconds) between messages:
MRPT_LOG_THROTTLE_DEBUG_STREAM(5.0, "Var=" << value << " foo=" << foo_var);
// Only once:
MRPT_LOG_ONCE_WARN("Notice: blah blah");

From outside of a class inheriting from COutputLogger the following MRPT_UNSCOPED_{START|END} macros are provided:

MRPT_LOG_ERROR_STREAM("error: " << strval);
  • Logger instance keeps the messages in an internal container so that upon request it can dump them either to the console or to an external file altogether.

  • The message, when printed in the terminal window, is colored according to the logger’s current verbosity/logging level (Logging level with which the underlying TMsg instance was instantiatedd). The available verbosity levels as well as their corresponding colors are listed below:





  • Logged messages are displayed in the screen if the current logger level is higher than m_min_verbosity_level (logger ignores those messages altogether). This can be used for filtering the output messages according to their importance (e.g. show only error messages by issuing setMinLoggingLevel(LVL_ERROR)). Default logging level is LVL_INFO.

User may receive callbacks whenever a message is displayed to console by using logRegisterCallback(). If for some reason the callbacks are not needed any more, use logDeregisterCallback() to stop receiving calls. This mechanism is useful in case of showing the messages to a GUI, transmiting them to a remote machine, etc.

By default every logged message is going to be dumped to the standard output as well (if VerbosityLevel > m_min_verbosity_level). Unset logging_enable_console_output class variable if that’s not the desired behavior

[New in MRPT 1.5.0]

See also:

setLoggingLevel, setMinLoggingLevel


#include <mrpt/system/COutputLogger.h>

class COutputLogger
    // structs

    struct TMsg;

    // construction

    COutputLogger(std::string_view name);

// direct descendants

template <
    size_t VEH_SIZE,
    size_t OBS_SIZE,
    size_t FEAT_SIZE,
    size_t ACT_SIZE,
    typename KFTYPE = double
class CKalmanFilterCapable;

template <class GRAPH_T = typename mrpt::graphs::CNetworkOfPoses2DInf>
class CRegistrationDeciderOrOptimizer;

class CGridMapAlignerApp;
class DataSourceRawlog;
class ICP_SLAM_App_Base;
class KFSLAMApp;
class MonteCarloLocalization_Base;
class RawlogGrabberApp;
class RBPF_SLAM_App_Base;
class CParticleFilter;
class CServerTCPSocket;
class CDetectorDoorCrossing;
class ScalarFactorGraph;

template <class GRAPH_T = typename mrpt::graphs::CNetworkOfPoses2DInf>
class CGraphSlamEngine;

class CWindowManager;
class CHierarchicalMapMHPartition;
class C2DRangeFinderAbstract;
class CCameraSensor;
class CCANBusReader;
class CGPSInterface;
class CNationalInstrumentsDAQ;
class CPhidgetInterfaceKitProximitySensors;
class CRoboticHeadInterface;
class CTuMicos;
class CRandomFieldGridMap2D;
class CRandomFieldGridMap3D;

template <typename VECTORTYPE = CVectorDouble, class USERPARAM = VECTORTYPE>
class CLevenbergMarquardtTempl;

template <
    typename NUMTYPE = double,
    typename DATASET = CMatrixDynamic<NUMTYPE>,
    typename MODEL = CMatrixDynamic<NUMTYPE>
class RANSAC_Template;

class CAbstractNavigator;
class CRobot2NavInterface;
class CIncrementalMapPartitioner;
class CMetricMapBuilder;
class CMetricMapsAlignmentAlgorithm;

template <
    class PARTICLE_TYPE,
    class MYSELF,
    mrpt::bayes::particle_storage_mode STORAGE
class PF_implementation;

class CControlledRateTimer;
class CTimeLogger;


COutputLogger(std::string_view name)

Construct a COutputLogger instance with the given name as the instance name.

Call to this constructor can be used instead of first initializing the object and then explicitly setting the name like in the following case:

COutputLogger a_logger;

Default class constructor.

Name of the logger is initialized to “logStr”