122 static std::array<mrpt::system::TConsoleColor, NUMBER_OF_VERBOSITY_LEVELS>&
128 static std::array<std::string, NUMBER_OF_VERBOSITY_LEVELS>&
309 mutable std::deque<TMsg>
329 template <
typename T>
348 #define INTERNAL_MRPT_LOG(_LVL, _STRING) this->logStr(_LVL, _STRING) 350 #define INTERNAL_MRPT_LOG_ONCE(_LVL, _STRING) \ 353 static once_flag = false; \ 357 this->logStr(_LVL, _STRING); \ 361 #define INTERNAL_MRPT_LOG_FMT(_LVL, _FMT_STRING, ...) \ 364 if (this->isLoggingLevelVisible(_LVL)) \ 366 this->logFmt(_LVL, _FMT_STRING, __VA_ARGS__); \ 370 #define INTERNAL_MRPT_LOG_STREAM(_LVL, __CONTENTS) \ 373 if (this->isLoggingLevelVisible(_LVL)) \ 375 ::mrpt::system::COutputLoggerStreamWrapper(_LVL, *this) \ 380 #define INTERNAL_MRPT_LOG_THROTTLE(_LVL, _PERIOD_SECONDS, _STRING) \ 383 if (this->isLoggingLevelVisible(_LVL)) \ 385 static mrpt::system::CTicTac tim; \ 386 if (tim.Tac() > _PERIOD_SECONDS) \ 389 this->logStr(_LVL, _STRING); \ 394 #define INTERNAL_MRPT_LOG_THROTTLE_STREAM(_LVL, _PERIOD_SECONDS, __CONTENTS) \ 397 if (this->isLoggingLevelVisible(_LVL)) \ 399 static mrpt::system::CTicTac tim; \ 400 if (tim.Tac() > _PERIOD_SECONDS) \ 403 ::mrpt::system::COutputLoggerStreamWrapper(_LVL, *this) \ 409 #define INTERNAL_MRPT_LOG_THROTTLE_FMT( \ 410 _LVL, _PERIOD_SECONDS, _FMT_STRING, ...) \ 413 if (this->isLoggingLevelVisible(_LVL)) \ 415 static mrpt::system::CTicTac tim; \ 416 if (tim.Tac() > _PERIOD_SECONDS) \ 419 this->logFmt(_LVL, _FMT_STRING, __VA_ARGS__); \ 425 #define MRPT_LOG_DEBUG(_STRING) \ 426 INTERNAL_MRPT_LOG(::mrpt::system::LVL_DEBUG, _STRING) 427 #define MRPT_LOG_INFO(_STRING) \ 428 INTERNAL_MRPT_LOG(::mrpt::system::LVL_INFO, _STRING) 429 #define MRPT_LOG_WARN(_STRING) \ 430 INTERNAL_MRPT_LOG(::mrpt::system::LVL_WARN, _STRING) 431 #define MRPT_LOG_ERROR(_STRING) \ 432 INTERNAL_MRPT_LOG(::mrpt::system::LVL_ERROR, _STRING) 435 #define MRPT_LOG_ONCE_DEBUG(_STRING) \ 436 INTERNAL_MRPT_LOG_ONCE(::mrpt::system::LVL_DEBUG, _STRING) 437 #define MRPT_LOG_ONCE_INFO(_STRING) \ 438 INTERNAL_MRPT_LOG_ONCE(::mrpt::system::LVL_INFO, _STRING) 439 #define MRPT_LOG_ONCE_WARN(_STRING) \ 440 INTERNAL_MRPT_LOG_ONCE(::mrpt::system::LVL_WARN, _STRING) 441 #define MRPT_LOG_ONCE_ERROR(_STRING) \ 442 INTERNAL_MRPT_LOG_ONCE(::mrpt::system::LVL_ERROR, _STRING) 445 #define MRPT_LOG_THROTTLE_DEBUG(_PERIOD_SECONDS, _STRING) \ 446 INTERNAL_MRPT_LOG_THROTTLE( \ 447 ::mrpt::system::LVL_DEBUG, _PERIOD_SECONDS, _STRING) 448 #define MRPT_LOG_THROTTLE_INFO(_PERIOD_SECONDS, _STRING) \ 449 INTERNAL_MRPT_LOG_THROTTLE( \ 450 ::mrpt::system::LVL_INFO, _PERIOD_SECONDS, _STRING) 451 #define MRPT_LOG_THROTTLE_WARN(_PERIOD_SECONDS, _STRING) \ 452 INTERNAL_MRPT_LOG_THROTTLE( \ 453 ::mrpt::system::LVL_WARN, _PERIOD_SECONDS, _STRING) 454 #define MRPT_LOG_THROTTLE_ERROR(_PERIOD_SECONDS, _STRING) \ 455 INTERNAL_MRPT_LOG_THROTTLE( \ 456 ::mrpt::system::LVL_ERROR, _PERIOD_SECONDS, _STRING) 459 #define MRPT_LOG_DEBUG_FMT(_FMT_STRING, ...) \ 460 INTERNAL_MRPT_LOG_FMT(::mrpt::system::LVL_DEBUG, _FMT_STRING, __VA_ARGS__) 461 #define MRPT_LOG_INFO_FMT(_FMT_STRING, ...) \ 462 INTERNAL_MRPT_LOG_FMT(::mrpt::system::LVL_INFO, _FMT_STRING, __VA_ARGS__) 463 #define MRPT_LOG_WARN_FMT(_FMT_STRING, ...) \ 464 INTERNAL_MRPT_LOG_FMT(::mrpt::system::LVL_WARN, _FMT_STRING, __VA_ARGS__) 465 #define MRPT_LOG_ERROR_FMT(_FMT_STRING, ...) \ 466 INTERNAL_MRPT_LOG_FMT(::mrpt::system::LVL_ERROR, _FMT_STRING, __VA_ARGS__) 469 #define MRPT_LOG_DEBUG_STREAM(__CONTENTS) \ 470 INTERNAL_MRPT_LOG_STREAM(::mrpt::system::LVL_DEBUG, __CONTENTS) 471 #define MRPT_LOG_INFO_STREAM(__CONTENTS) \ 472 INTERNAL_MRPT_LOG_STREAM(::mrpt::system::LVL_INFO, __CONTENTS) 473 #define MRPT_LOG_WARN_STREAM(__CONTENTS) \ 474 INTERNAL_MRPT_LOG_STREAM(::mrpt::system::LVL_WARN, __CONTENTS) 475 #define MRPT_LOG_ERROR_STREAM(__CONTENTS) \ 476 INTERNAL_MRPT_LOG_STREAM(::mrpt::system::LVL_ERROR, __CONTENTS) 480 #define MRPT_LOG_THROTTLE_DEBUG_STREAM(_PERIOD_SECONDS, __CONTENTS) \ 481 INTERNAL_MRPT_LOG_THROTTLE_STREAM( \ 482 ::mrpt::system::LVL_DEBUG, _PERIOD_SECONDS, __CONTENTS) 483 #define MRPT_LOG_THROTTLE_INFO_STREAM(_PERIOD_SECONDS, __CONTENTS) \ 484 INTERNAL_MRPT_LOG_THROTTLE_STREAM( \ 485 ::mrpt::system::LVL_INFO, _PERIOD_SECONDS, __CONTENTS) 486 #define MRPT_LOG_THROTTLE_WARN_STREAM(_PERIOD_SECONDS, __CONTENTS) \ 487 INTERNAL_MRPT_LOG_THROTTLE_STREAM( \ 488 ::mrpt::system::LVL_WARN, _PERIOD_SECONDS, __CONTENTS) 489 #define MRPT_LOG_THROTTLE_ERROR_STREAM(_PERIOD_SECONDS, __CONTENTS) \ 490 INTERNAL_MRPT_LOG_THROTTLE_STREAM( \ 491 ::mrpt::system::LVL_ERROR, _PERIOD_SECONDS, __CONTENTS) 494 #define MRPT_LOG_THROTTLE_DEBUG_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \ 495 INTERNAL_MRPT_LOG_THROTTLE_FMT( \ 496 ::mrpt::system::LVL_DEBUG, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__) 497 #define MRPT_LOG_THROTTLE_INFO_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \ 498 INTERNAL_MRPT_LOG_THROTTLE_FMT( \ 499 ::mrpt::system::LVL_INFO, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__) 500 #define MRPT_LOG_THROTTLE_WARN_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \ 501 INTERNAL_MRPT_LOG_THROTTLE_FMT( \ 502 ::mrpt::system::LVL_WARN, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__) 503 #define MRPT_LOG_THROTTLE_ERROR_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \ 504 INTERNAL_MRPT_LOG_THROTTLE_FMT( \ 505 ::mrpt::system::LVL_ERROR, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__) 508 #define DEFAULT_LOGLVL_MRPT_UNSCOPED ::mrpt::system::LVL_DEBUG 510 #define DEFAULT_LOGLVL_MRPT_UNSCOPED ::mrpt::system::LVL_DEBUG 525 #define MRPT_UNSCOPED_LOGGER_START \ 528 struct dummy_logger_ : public mrpt::system::COutputLogger \ 530 dummy_logger_() : mrpt::system::COutputLogger("MRPT_log") \ 532 this->setMinLoggingLevel(DEFAULT_LOGLVL_MRPT_UNSCOPED); \ 542 #define MRPT_UNSCOPED_LOGGER_END \ 546 static dummy_logger_ tmp_obj; \ 547 tmp_obj.usercode(); \ bool isLoggingLevelVisible(VerbosityLevel level) const
#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
TMsg(const mrpt::system::VerbosityLevel level, const std::string &msg, const COutputLogger &logger)
Class constructor that passes a message in std::string form as well as a reference to the COutputLogg...
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::string generateStringFromFormat(const char *fmt, va_list argp) const
Helper method for generating a std::string instance from printf-like arguments.
std::stringstream & operator<<(const T &val)
COutputLoggerStreamWrapper(VerbosityLevel level, const COutputLogger &logger)
VerbosityLevel getMinLoggingLevel() const
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 writeLogToFile(const std::string *fname_in=NULL) const
Write the contents of the COutputLogger instance to an external file.
std::function< void(const std::string &msg, const mrpt::system::VerbosityLevel level, const std::string &loggerName, const mrpt::Clock::time_point ×tamp)> output_logger_callback_t
Callback types for use with mrpt::system::COuputLogger.
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)
GLsizei const GLchar ** string
mrpt::Clock::time_point timestamp
Timestamp of the message.
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
COutputLogger()
Default class constructor.
Struct responsible of holding information relevant to the message (in std::string form) issued by the...
GLuint const GLchar * name
void logRegisterCallback(output_logger_callback_t userFunc)
std::string name
Name of the COutputLogger instance that called registered the message.
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
MRPT_FILL_ENUM_CUSTOM_NAME(LVL_DEBUG, "DEBUG")
~COutputLoggerStreamWrapper()
void logStr(const VerbosityLevel level, const std::string &msg_str) const
Main method to add the specified message string to the logger.
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)