Go to the documentation of this file.
181 const std::
string& msg_str) 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 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(); \
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...
mrpt::system::TTimeStamp timestamp
Timestamp of the message.
static mrpt::system::TConsoleColor logging_levels_to_colors[NUMBER_OF_VERBOSITY_LEVELS]
Map from VerbosityLevels to their corresponding mrpt::system::TConsoleColor.
bool isLoggingLevelVisible(VerbosityLevel level) const
void logStr(const VerbosityLevel level, const std::string &msg_str) const
Main method to add the specified message string to the logger.
const COutputLogger & m_logger
void dumpToConsole() const
Dump the message contents to the standard output.
void reset()
Reset the contents of the TMsg instance.
#define MRPT_ENUM_TYPE_END()
void writeToStream(std::ostream &out) const
Write the message contents to the specified stream.
MRPT_FILL_ENUM_CUSTOM_NAME(LVL_DEBUG, "DEBUG")
virtual ~COutputLogger()
virtual dtor (so we can derive classes from this one)
void setVerbosityLevel(const VerbosityLevel level)
alias of setMinLoggingLevel()
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 ...
std::stringstream & operator<<(const T &val)
std::string generateStringFromFormat(const char *fmt, va_list argp) const
Helper method for generating a std::string instance from printf-like arguments.
VerbosityLevel m_min_verbosity_level
Provided messages with VerbosityLevel smaller than this value shall be ignored.
void writeLogToFile(const std::string *fname_in=NULL) const
Write the contents of the COutputLogger instance to an external file.
bool logging_enable_keep_record
[Default=false] Enables storing all messages into an internal list.
std::string getLoggerLastMsg() const
Return the last Tmsg instance registered in the logger history.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLuint const GLchar * name
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
std::string getLoggerName() const
Return the name of the COutputLogger 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.
std::string getLogAsString() const
Get the history of COutputLogger instance in a string representation.
void logFmt(const VerbosityLevel level, const char *fmt,...) const MRPT_printf_format_check(3
Alternative logging method, which mimics the printf behavior.
std::deque< output_logger_callback_t > m_listCallbacks
VerbosityLevel
Enumeration of available verbosity levels.
std::stringstream & operator<<(const std::stringstream &val)
std::string body
Actual content of the message.
For use in MRPT_LOG_DEBUG_STREAM(), etc.
VerbosityLevel level
Verbosity level of the message.
std::string getAsString() const
Return a string representation of the underlying message.
void setMinLoggingLevel(const VerbosityLevel level)
Set the minimum logging level for which the incoming logs are going to be taken into account.
#define MRPT_ENUM_TYPE_BEGIN_NAMESPACE(_NAMESPACE, _ENUM_TYPE_WITH_NS)
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
~TMsg()
Default Destructor.
void loggerReset()
Reset the contents of the logger instance.
bool logDeregisterCallback(output_logger_callback_t userFunc)
Versatile class for consistent logging and management of output messages.
COutputLoggerStreamWrapper(VerbosityLevel level, const COutputLogger &logger)
void dumpLogToConsole() const
Dump the current contents of the COutputLogger instance in the terminal window.
TConsoleColor
For use in setConsoleColor.
std::string m_logger_name
Struct responsible of holding information relevant to the message (in std::string form) issued by the...
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
void logRegisterCallback(output_logger_callback_t userFunc)
GLsizei const GLchar ** string
static std::string logging_levels_to_names[NUMBER_OF_VERBOSITY_LEVELS]
Map from VerbosityLevels to their corresponding names.
VerbosityLevel getMinLoggingLevel() const
void setLoggerName(const std::string &name)
Set the name of the COutputLogger instance.
~COutputLoggerStreamWrapper()
std::deque< TMsg > m_history
@ NUMBER_OF_VERBOSITY_LEVELS
COutputLogger()
Default class constructor.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
std::function< void(const std::string &msg, const mrpt::system::VerbosityLevel level, const std::string &loggerName, const mrpt::system::TTimeStamp timestamp)> output_logger_callback_t
Callback types for use with mrpt::system::COuputLogger.
std::string name
Name of the COutputLogger instance that called registered the message.
MRPT_FILL_ENUM(LVL_DEBUG)
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |