23 #include <string_view>   123     static std::array<mrpt::system::TConsoleColor, NUMBER_OF_VERBOSITY_LEVELS>&
   129     static std::array<std::string, NUMBER_OF_VERBOSITY_LEVELS>&
   182         const std::string& msg_str) 
const;
   308         std::string_view fmt, va_list argp) 
const;
   311     mutable std::deque<TMsg>
   331     template <
typename T>
   350 #define INTERNAL_MRPT_LOG(_LVL, _STRING) this->logStr(_LVL, _STRING)   352 #define INTERNAL_MRPT_LOG_ONCE(_LVL, _STRING) \   355         static bool once_flag = false;        \   359             this->logStr(_LVL, _STRING);      \   363 #define INTERNAL_MRPT_LOG_FMT(_LVL, _FMT_STRING, ...)     \   366         if (this->isLoggingLevelVisible(_LVL))            \   368             this->logFmt(_LVL, _FMT_STRING, __VA_ARGS__); \   372 #define INTERNAL_MRPT_LOG_STREAM(_LVL, __CONTENTS)                  \   375         if (this->isLoggingLevelVisible(_LVL))                      \   377             ::mrpt::system::COutputLoggerStreamWrapper(_LVL, *this) \   382 #define INTERNAL_MRPT_LOG_THROTTLE(_LVL, _PERIOD_SECONDS, _STRING) \   385         if (this->isLoggingLevelVisible(_LVL))                     \   387             static mrpt::system::CTicTac tim;                      \   388             if (tim.Tac() > _PERIOD_SECONDS)                       \   391                 this->logStr(_LVL, _STRING);                       \   396 #define INTERNAL_MRPT_LOG_THROTTLE_STREAM(_LVL, _PERIOD_SECONDS, __CONTENTS) \   399         if (this->isLoggingLevelVisible(_LVL))                               \   401             static mrpt::system::CTicTac tim;                                \   402             if (tim.Tac() > _PERIOD_SECONDS)                                 \   405                 ::mrpt::system::COutputLoggerStreamWrapper(_LVL, *this)      \   411 #define INTERNAL_MRPT_LOG_THROTTLE_FMT(                       \   412     _LVL, _PERIOD_SECONDS, _FMT_STRING, ...)                  \   415         if (this->isLoggingLevelVisible(_LVL))                \   417             static mrpt::system::CTicTac tim;                 \   418             if (tim.Tac() > _PERIOD_SECONDS)                  \   421                 this->logFmt(_LVL, _FMT_STRING, __VA_ARGS__); \   427 #define MRPT_LOG_DEBUG(_STRING) \   428     INTERNAL_MRPT_LOG(::mrpt::system::LVL_DEBUG, _STRING)   429 #define MRPT_LOG_INFO(_STRING) \   430     INTERNAL_MRPT_LOG(::mrpt::system::LVL_INFO, _STRING)   431 #define MRPT_LOG_WARN(_STRING) \   432     INTERNAL_MRPT_LOG(::mrpt::system::LVL_WARN, _STRING)   433 #define MRPT_LOG_ERROR(_STRING) \   434     INTERNAL_MRPT_LOG(::mrpt::system::LVL_ERROR, _STRING)   437 #define MRPT_LOG_ONCE_DEBUG(_STRING) \   438     INTERNAL_MRPT_LOG_ONCE(::mrpt::system::LVL_DEBUG, _STRING)   439 #define MRPT_LOG_ONCE_INFO(_STRING) \   440     INTERNAL_MRPT_LOG_ONCE(::mrpt::system::LVL_INFO, _STRING)   441 #define MRPT_LOG_ONCE_WARN(_STRING) \   442     INTERNAL_MRPT_LOG_ONCE(::mrpt::system::LVL_WARN, _STRING)   443 #define MRPT_LOG_ONCE_ERROR(_STRING) \   444     INTERNAL_MRPT_LOG_ONCE(::mrpt::system::LVL_ERROR, _STRING)   447 #define MRPT_LOG_THROTTLE_DEBUG(_PERIOD_SECONDS, _STRING) \   448     INTERNAL_MRPT_LOG_THROTTLE(                           \   449         ::mrpt::system::LVL_DEBUG, _PERIOD_SECONDS, _STRING)   450 #define MRPT_LOG_THROTTLE_INFO(_PERIOD_SECONDS, _STRING) \   451     INTERNAL_MRPT_LOG_THROTTLE(                          \   452         ::mrpt::system::LVL_INFO, _PERIOD_SECONDS, _STRING)   453 #define MRPT_LOG_THROTTLE_WARN(_PERIOD_SECONDS, _STRING) \   454     INTERNAL_MRPT_LOG_THROTTLE(                          \   455         ::mrpt::system::LVL_WARN, _PERIOD_SECONDS, _STRING)   456 #define MRPT_LOG_THROTTLE_ERROR(_PERIOD_SECONDS, _STRING) \   457     INTERNAL_MRPT_LOG_THROTTLE(                           \   458         ::mrpt::system::LVL_ERROR, _PERIOD_SECONDS, _STRING)   461 #define MRPT_LOG_DEBUG_FMT(_FMT_STRING, ...) \   462     INTERNAL_MRPT_LOG_FMT(::mrpt::system::LVL_DEBUG, _FMT_STRING, __VA_ARGS__)   463 #define MRPT_LOG_INFO_FMT(_FMT_STRING, ...) \   464     INTERNAL_MRPT_LOG_FMT(::mrpt::system::LVL_INFO, _FMT_STRING, __VA_ARGS__)   465 #define MRPT_LOG_WARN_FMT(_FMT_STRING, ...) \   466     INTERNAL_MRPT_LOG_FMT(::mrpt::system::LVL_WARN, _FMT_STRING, __VA_ARGS__)   467 #define MRPT_LOG_ERROR_FMT(_FMT_STRING, ...) \   468     INTERNAL_MRPT_LOG_FMT(::mrpt::system::LVL_ERROR, _FMT_STRING, __VA_ARGS__)   471 #define MRPT_LOG_DEBUG_STREAM(__CONTENTS) \   472     INTERNAL_MRPT_LOG_STREAM(::mrpt::system::LVL_DEBUG, __CONTENTS)   473 #define MRPT_LOG_INFO_STREAM(__CONTENTS) \   474     INTERNAL_MRPT_LOG_STREAM(::mrpt::system::LVL_INFO, __CONTENTS)   475 #define MRPT_LOG_WARN_STREAM(__CONTENTS) \   476     INTERNAL_MRPT_LOG_STREAM(::mrpt::system::LVL_WARN, __CONTENTS)   477 #define MRPT_LOG_ERROR_STREAM(__CONTENTS) \   478     INTERNAL_MRPT_LOG_STREAM(::mrpt::system::LVL_ERROR, __CONTENTS)   482 #define MRPT_LOG_THROTTLE_DEBUG_STREAM(_PERIOD_SECONDS, __CONTENTS) \   483     INTERNAL_MRPT_LOG_THROTTLE_STREAM(                              \   484         ::mrpt::system::LVL_DEBUG, _PERIOD_SECONDS, __CONTENTS)   485 #define MRPT_LOG_THROTTLE_INFO_STREAM(_PERIOD_SECONDS, __CONTENTS) \   486     INTERNAL_MRPT_LOG_THROTTLE_STREAM(                             \   487         ::mrpt::system::LVL_INFO, _PERIOD_SECONDS, __CONTENTS)   488 #define MRPT_LOG_THROTTLE_WARN_STREAM(_PERIOD_SECONDS, __CONTENTS) \   489     INTERNAL_MRPT_LOG_THROTTLE_STREAM(                             \   490         ::mrpt::system::LVL_WARN, _PERIOD_SECONDS, __CONTENTS)   491 #define MRPT_LOG_THROTTLE_ERROR_STREAM(_PERIOD_SECONDS, __CONTENTS) \   492     INTERNAL_MRPT_LOG_THROTTLE_STREAM(                              \   493         ::mrpt::system::LVL_ERROR, _PERIOD_SECONDS, __CONTENTS)   496 #define MRPT_LOG_THROTTLE_DEBUG_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \   497     INTERNAL_MRPT_LOG_THROTTLE_FMT(                                    \   498         ::mrpt::system::LVL_DEBUG, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__)   499 #define MRPT_LOG_THROTTLE_INFO_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \   500     INTERNAL_MRPT_LOG_THROTTLE_FMT(                                   \   501         ::mrpt::system::LVL_INFO, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__)   502 #define MRPT_LOG_THROTTLE_WARN_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \   503     INTERNAL_MRPT_LOG_THROTTLE_FMT(                                   \   504         ::mrpt::system::LVL_WARN, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__)   505 #define MRPT_LOG_THROTTLE_ERROR_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \   506     INTERNAL_MRPT_LOG_THROTTLE_FMT(                                    \   507         ::mrpt::system::LVL_ERROR, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__)   510 #define DEFAULT_LOGLVL_MRPT_UNSCOPED ::mrpt::system::LVL_DEBUG   512 #define DEFAULT_LOGLVL_MRPT_UNSCOPED ::mrpt::system::LVL_DEBUG   527 #define MRPT_UNSCOPED_LOGGER_START                                      \   530         struct dummy_logger_ : public mrpt::system::COutputLogger       \   532             dummy_logger_() : mrpt::system::COutputLogger("MRPT_log")   \   534                 this->setMinLoggingLevel(DEFAULT_LOGLVL_MRPT_UNSCOPED); \   544 #define MRPT_UNSCOPED_LOGGER_END  \   548     static dummy_logger_ tmp_obj; \   549     tmp_obj.usercode();           \ bool isLoggingLevelVisible(VerbosityLevel level) const
 
std::string generateStringFromFormat(std::string_view fmt, va_list argp) const
Helper method for generating a std::string instance from printf-like arguments. 
 
#define MRPT_ENUM_TYPE_BEGIN_NAMESPACE(_NAMESPACE, _ENUM_TYPE_WITH_NS)
 
VerbosityLevel
Enumeration of available verbosity levels. 
 
virtual ~COutputLogger()
virtual dtor (so we can derive classes from this one) 
 
std::chrono::time_point< Clock > time_point
 
void logFmt(const VerbosityLevel level, const char *fmt,...) const MRPT_printf_format_check(3
Alternative logging method, which mimics the printf behavior. 
 
void dumpToConsole() const
Dump the message contents to the standard output. 
 
std::string getLoggerLastMsg() const
Return the last Tmsg instance registered in the logger history. 
 
static std::array< std::string, NUMBER_OF_VERBOSITY_LEVELS > & logging_levels_to_names()
Map from VerbosityLevels to their corresponding names. 
 
void setMinLoggingLevel(const VerbosityLevel level)
Set the minimum logging level for which the incoming logs are going to be taken into account...
 
MRPT_FILL_ENUM(LVL_DEBUG)
 
For use in MRPT_LOG_DEBUG_STREAM(), etc. 
 
void writeToStream(std::ostream &out) const
Write the message contents to the specified stream. 
 
const COutputLogger & m_logger
 
std::deque< output_logger_callback_t > m_listCallbacks
 
bool logging_enable_keep_record
[Default=false] Enables storing all messages into an internal list. 
 
VerbosityLevel level
Verbosity level of the message. 
 
std::stringstream & operator<<(const T &val)
 
COutputLoggerStreamWrapper(VerbosityLevel level, const COutputLogger &logger)
 
VerbosityLevel getMinLoggingLevel() const
 
std::function< void(std::string_view msg, const mrpt::system::VerbosityLevel level, std::string_view loggerName, const mrpt::Clock::time_point timestamp)> output_logger_callback_t
Callback types for use with mrpt::system::COuputLogger. 
 
static std::array< mrpt::system::TConsoleColor, NUMBER_OF_VERBOSITY_LEVELS > & logging_levels_to_colors()
Map from VerbosityLevels to their corresponding mrpt::system::TConsoleColor. 
 
std::string getAsString() const
Return a string representation of the underlying message. 
 
std::string body
Actual content of the message. 
 
Versatile class for consistent logging and management of output messages. 
 
std::string getLoggerName() const
Return the name of the COutputLogger instance. 
 
std::string m_logger_name
 
void setLoggerName(const std::string &name)
Set the name of the COutputLogger instance. 
 
void loggerReset()
Reset the contents of the logger instance. 
 
void void logCond(const VerbosityLevel level, bool cond, const std::string &msg_str) const
Log the given message only if the condition is satisfied. 
 
#define MRPT_ENUM_TYPE_END()
 
void dumpLogToConsole() const
Dump the current contents of the COutputLogger instance in the terminal window. 
 
std::stringstream & operator<<(const std::stringstream &val)
 
mrpt::Clock::time_point timestamp
Timestamp of the message. 
 
TMsg(const mrpt::system::VerbosityLevel level, std::string_view msg, const COutputLogger &logger)
Class constructor that passes a message in std::string form as well as a reference to the COutputLogg...
 
std::string getLogAsString() const
Get the history of COutputLogger instance in a string representation. 
 
void setVerbosityLevel(const VerbosityLevel level)
alias of setMinLoggingLevel() 
 
std::deque< TMsg > m_history
 
void logStr(const VerbosityLevel level, std::string_view msg_str) const
Main method to add the specified message string to the logger. 
 
mrpt::vision::TStereoCalibResults out
 
COutputLogger()
Default class constructor. 
 
Struct responsible of holding information relevant to the message (in std::string form) issued by the...
 
void logRegisterCallback(output_logger_callback_t userFunc)
 
std::string name
Name of the COutputLogger instance that called registered the message. 
 
MRPT_FILL_ENUM_CUSTOM_NAME(LVL_DEBUG, "DEBUG")
 
~COutputLoggerStreamWrapper()
 
VerbosityLevel m_min_verbosity_level
Provided messages with VerbosityLevel smaller than this value shall be ignored. 
 
~TMsg()
Default Destructor. 
 
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
 
bool logging_enable_console_output
[Default=true] Set it to false in case you don't want the logged messages to be dumped to the output ...
 
bool logDeregisterCallback(output_logger_callback_t userFunc)
 
void writeLogToFile(const std::string *fname_in=nullptr) const
Write the contents of the COutputLogger instance to an external file.