Main MRPT website > C++ reference for MRPT 1.9.9
COutputLogger.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef COUTPUTLOGGER_H
11 #define COUTPUTLOGGER_H
12 
13 #include <mrpt/utils/mrpt_macros.h>
14 #include <mrpt/utils/TEnumType.h>
15 #include <mrpt/system/os.h> // for console color constants
16 #include <mrpt/utils/CTicTac.h>
17 
18 #include <string>
19 #include <deque>
20 #include <mrpt/system/datetime.h>
21 #include <sstream>
22 #include <set>
23 
24 namespace mrpt
25 {
26 namespace utils
27 {
28 class CStream; // frwd decl
29 
30 /** \brief Enumeration of available verbosity levels. \sa COutputLogger */
31 enum VerbosityLevel
32 {
33  LVL_DEBUG = 0,
34  LVL_INFO,
35  LVL_WARN,
36  LVL_ERROR,
37  // ------------
38  NUMBER_OF_VERBOSITY_LEVELS
39 };
40 
41 /** Callback types for use with mrpt::utils::COuputLogger */
42 typedef void (*output_logger_callback_t)(
43  const std::string& msg, const mrpt::utils::VerbosityLevel level,
44  const std::string& loggerName, const mrpt::system::TTimeStamp timestamp,
45  void* userParam);
46 
47 /** \brief Versatile class for consistent logging and
48  * management of output messages
49  *
50  * COutputLogger is a versatile class for logging messages either to the
51  * terminal window or to an external file. Class instances can take messages in
52  * std::string using the logStr class methods. The following macros are also
53  * provided
54  * for usage within a class that inherits from COutputLogger:
55  *
56  * \code
57  * // Plain strings:
58  * MRPT_LOG_DEBUG("This will be shown only if verbosity level is LVL_DEBUG.");
59  * MRPT_LOG_ERROR("This message will be always shown.");
60  * // printf-like versions:
61  * MRPT_LOG_ERROR_FMT("Out of range value: %i.", int_param);
62  * // stream-like versions:
63  * MRPT_LOG_ERROR_STREAM("Out of range value: " << int_param << " more vars: "
64  * << other_var);
65  * // Minimum period (in seconds) between messages:
66  * MRPT_LOG_THROTTLE_DEBUG_STREAM(5.0, "Var=" << value << " foo=" << foo_var);
67  * // Only once:
68  * MRPT_LOG_ONCE_WARN("Notice: blah blah");
69  * \endcode
70  *
71  * From outside of a class inheriting from COutputLogger the following
72  * `MRPT_UNSCOPED_{START|END}` macros are provided:
73  *
74  * \code
75  * MRPT_UNSCOPED_LOGGER_START;
76  * MRPT_LOG_WARN("blah");
77  * MRPT_LOG_ERROR_STREAM("error: " << strval);
78  * MRPT_UNSCOPED_LOGGER_END;
79  * \endcode
80  *
81  * - Logger instance keeps the messages in an internal container so that upon
82  * request it can dump them either to the console or to an external file
83  * altogether.
84  * - The message, when printed in the terminal window, is **colored** according
85  * to
86  * the logger's current verbosity/logging level (Logging level with which
87  * the underlying TMsg instance was instantiatedd). The available verbosity
88  * levels as well as their corresponding colors are listed below:
89  *
90  * + LVL_DEBUG => CONCOL_BLUE
91  * + LVL_INFO => CONCOL_NORMAL
92  * + LVL_WARN => CONCOL_GREEN
93  * + LVL_ERROR => CONCOL_RED
94  *
95  * - Logged messages are displayed in the screen if the current logger level is
96  * higher than m_min_verbosity_level (logger ignores those messages
97  * altogether). This can be used for filtering the output messages according
98  * to their importance (e.g. show only error messages by issuing
99  * setMinLoggingLevel(LVL_ERROR)).
100  * \sa setLoggingLevel, setMinLoggingLevel
101  *
102  * Default logging level is LVL_INFO.
103  *
104  * User may receive callbacks whenever a message is displayed to console by
105  * using
106  * logRegisterCallback(). If for some reason the callbacks are not needed any
107  * more,
108  * use logDeregisterCallback() to stop receiving calls. This mechanism is useful
109  * in case of showing the messages to a GUI, transmiting them to a remote
110  * machine, etc.
111  *
112  * \note By default every logged message is going to be dumped to the standard
113  * output as well (if VerbosityLevel > m_min_verbosity_level). Unset \b
114  * logging_enable_console_output class variable if that's not the desired
115  * behavior
116  *
117  * \note [New in MRPT 1.5.0]
118  * \sa TMsg
119  * \ingroup mrpt_base_grp
120  */
121 class COutputLogger
122 {
123  public:
124  static mrpt::system::TConsoleColor logging_levels_to_colors
125  [NUMBER_OF_VERBOSITY_LEVELS]; //! Map from VerbosityLevels to their
126  //! corresponding
127  //! mrpt::system::TConsoleColor. Handy
128  //! for coloring the input based on the
129  //! verbosity of the message
130  /** Map from VerbosityLevels to their corresponding names. Handy for
131  * printing the current message VerbosityLevel along with the actual content
132  */
133  static std::string logging_levels_to_names[NUMBER_OF_VERBOSITY_LEVELS];
134 
135  /** @name Logging methods
136  * @{ */
137 
138  /**
139  * \brief Construct a COutputLogger instance with the given name as the
140  * instance name.
141  *
142  * Call to this constructor can be used instead of first initializing the
143  * object and then explicitly setting the name like in the following case:
144  * \code
145  * COutputLogger a_logger;
146  * a_logger.setLoggerName("logger_name");
147  * \endcode
148  */
149  COutputLogger(const std::string& name);
150  /** Default class constructor. Name of the logger is initialized to "logStr"
151  */
152  COutputLogger();
153  /** virtual dtor (so we can derive classes from this one) */
154  virtual ~COutputLogger();
155 
156  /** \brief Main method to add the specified message string to the logger.
157  * \sa logCond, logFmt */
158  void logStr(const VerbosityLevel level, const std::string& msg_str)
159  const; // renamed from log() to avoid conflict with math ::log()
160 
161  /** \brief Alternative logging method, which mimics the printf behavior.
162  *
163  * Handy for not having to first use mrpt::format to pass a std::string
164  * message to logStr
165  *
166  * \code
167  * // instead of:
168  * logStr(mrpt::format("Today is the %d of %s, %d", 15, "July", 2016));
169  *
170  * // one can use:
171  * logFmt("Today is the %d of %s, %d", 15, "July", 2016);
172  * \endcode
173  *
174  * \sa logStr, logCond
175  */
176  void logFmt(const VerbosityLevel level, const char* fmt, ...) const
177  MRPT_printf_format_check(3, 4); // arg 1=this
178 
179  /** \brief Log the given message only if the condition is satisfied.
180  *
181  * \sa log, logFmt
182  */
183  void logCond(
184  const VerbosityLevel level, bool cond,
185  const std::string& msg_str) const;
186 
187  /** Set the name of the COutputLogger instance. \sa getLoggerName */
188  void setLoggerName(const std::string& name);
189  /** Return the name of the COutputLogger instance. \sa setLoggerName */
190  std::string getLoggerName() const;
191 
192  /** \brief Set the *minimum* logging level for which the incoming logs are
193  * going to be taken into account.
194  *
195  * String messages with specified VerbosityLevel smaller than the min, will
196  * not be outputted to the screen and neither will a record of them be
197  * stored in by the COutputLogger instance
198  */
199  void setMinLoggingLevel(const VerbosityLevel level);
200  /** alias of setMinLoggingLevel() */
201  void setVerbosityLevel(const VerbosityLevel level);
202 
203  /** \sa setMinLoggingLevel */
204  VerbosityLevel getMinLoggingLevel() const { return m_min_verbosity_level; }
205  bool isLoggingLevelVisible(VerbosityLevel level) const
206  {
207  return m_min_verbosity_level <= level;
208  }
209 
210  /** Fill the provided string with the contents of the logger's history in
211  * std::string representation */
212  void getLogAsString(std::string& log_contents) const;
213  /** Get the history of COutputLogger instance in a string representation. */
214  std::string getLogAsString() const;
215 
216  /** \brief Write the contents of the COutputLogger instance to an external
217  * file.
218  *
219  * Upon call to this method, COutputLogger dumps the contents of all the
220  * logged commands so far to the specified external file. By default the
221  * filename is set to ${LOGGERNAME}.log except if the fname parameter is
222  * provided
223  *
224  * \sa dumpToConsole, getAsString
225  */
226  void writeLogToFile(const std::string* fname_in = NULL) const;
227  /** \brief Dump the current contents of the COutputLogger instance in the
228  * terminal window.
229  *
230  * \sa writeToFile
231  */
232  void dumpLogToConsole() const;
233  /** Return the last Tmsg instance registered in the logger history */
234  std::string getLoggerLastMsg() const;
235  /** Fill inputtted string with the contents of the last message in history
236  */
237  void getLoggerLastMsg(std::string& msg_str) const;
238  /** Reset the contents of the logger instance. Called upon construction. */
239  void loggerReset();
240 
241  /** [Default=true] Set it to false in case you don't want the logged
242  * messages to be dumped to the output automatically. */
243  bool logging_enable_console_output;
244  /** [Default=false] Enables storing all messages into an internal list. \sa
245  * writeLogToFile, getLogAsString */
246  bool logging_enable_keep_record;
247 
248  void logRegisterCallback(
249  output_logger_callback_t userFunc, void* userParam = NULL);
250  void logDeregisterCallback(
251  output_logger_callback_t userFunc, void* userParam = NULL);
252  /** @} */
253 
254  struct TCallbackEntry
255  {
256  output_logger_callback_t func;
257  void* userParam;
258 
259  bool operator<(
260  const mrpt::utils::COutputLogger::TCallbackEntry& e2) const
261  {
262  return func < e2.func;
263  }
264  bool operator==(
265  const mrpt::utils::COutputLogger::TCallbackEntry& c2) const
266  {
267  return func == c2.func && userParam == c2.userParam;
268  }
269  };
270 
271  protected:
272  /** \brief Provided messages with VerbosityLevel smaller than this value
273  * shall be ignored */
274  VerbosityLevel m_min_verbosity_level;
275 
276  private:
277  /**
278  * \brief Struct responsible of holding information relevant to the message
279  * (in std::string form) issued by the user.
280  *
281  * Upon TMsg initialization, instance fetches the name of the caller
282  * COutputLogger, as well as the VerbosityLevel and the
283  * mrpt::system::TTimeStamp of the message provided.
284  * The format of the message when this is printed / or written to an
285  * external file complies is given below:
286  *
287  * <center><em> [name | level | timestamp:] body </em></center>
288  */
289  struct TMsg
290  {
291  /** \brief Class constructor that passes a message in std::string
292  * form as well as a reference to the COutputLogger that provided the
293  * current message
294  */
295  TMsg(
296  const mrpt::utils::VerbosityLevel level, const std::string& msg,
297  const COutputLogger& logger);
298  /** \brief Default Destructor */
299  ~TMsg();
300 
301  /** \brief Return a string representation of the underlying message */
302  std::string getAsString() const;
303  /** \brief Fill the string with the contents of the underlying message
304  * in
305  * string representation */
306  void getAsString(std::string* contents) const;
307  /** \brief Write the message contents to the specified stream
308  *
309  * \sa getAsString
310  */
311  void writeToStream(mrpt::utils::CStream& out) const;
312  /** \brief Dump the message contents to the standard output
313  *
314  * \sa writeToStream
315  */
316  void dumpToConsole() const;
317  /** \brief Reset the contents of the TMsg instance */
318  void reset();
319 
320  // parameters of the message under construction
321  mrpt::system::TTimeStamp timestamp; /**< Timestamp of the message. */
322  VerbosityLevel level; /**< Verbosity level of the message. */
323  std::string name; /**< Name of the COutputLogger instance that called
324  registered the message. */
325  std::string body; /**< Actual content of the message. */
326  };
327 
328  /** Helper method for generating a std::string instance from printf-like
329  * arguments */
330  std::string generateStringFromFormat(const char* fmt, va_list argp) const;
331 
332  std::string m_logger_name;
333  mutable std::deque<TMsg>
334  m_history; // deque is better than vector to avoid memory reallocs
335 
336  std::set<TCallbackEntry> m_listCallbacks;
337 };
338 
339 /** For use in MRPT_LOG_DEBUG_STREAM(), etc. */
340 struct COutputLoggerStreamWrapper
341 {
342  COutputLoggerStreamWrapper(
343  VerbosityLevel level, const COutputLogger& logger)
344  : m_level(level), m_logger(logger)
345  {
346  }
347  ~COutputLoggerStreamWrapper()
348  {
349  if (m_logger.isLoggingLevelVisible(m_level))
350  m_logger.logStr(m_level, m_str.str());
351  }
352 
353  template <typename T>
354  std::stringstream& operator<<(const T& val)
355  {
356  m_str << val;
357  return m_str;
358  }
359  // Overload for std::stringstream objects
360  std::stringstream& operator<<(const std::stringstream& val)
361  {
362  m_str << val.str();
363  return m_str;
364  }
365 
366  private:
367  std::stringstream m_str;
368  VerbosityLevel m_level;
369  const COutputLogger& m_logger;
370 };
371 
372 #define INTERNAL_MRPT_LOG(_LVL, _STRING) this->logStr(_LVL, _STRING)
373 
374 #define INTERNAL_MRPT_LOG_ONCE(_LVL, _STRING) \
375  do \
376  { \
377  static once_flag = false; \
378  if (!once_flag) \
379  { \
380  once_flag = true; \
381  this->logStr(_LVL, _STRING); \
382  } \
383  } while (0)
384 
385 #define INTERNAL_MRPT_LOG_FMT(_LVL, _FMT_STRING, ...) \
386  do \
387  { \
388  if (this->isLoggingLevelVisible(_LVL)) \
389  { \
390  this->logFmt(_LVL, _FMT_STRING, __VA_ARGS__); \
391  } \
392  } while (0)
393 
394 #define INTERNAL_MRPT_LOG_STREAM(_LVL, __CONTENTS) \
395  do \
396  { \
397  if (this->isLoggingLevelVisible(_LVL)) \
398  { \
399  ::mrpt::utils::COutputLoggerStreamWrapper(_LVL, *this) \
400  << __CONTENTS; \
401  } \
402  } while (0)
403 
404 #define INTERNAL_MRPT_LOG_THROTTLE(_LVL, _PERIOD_SECONDS, _STRING) \
405  do \
406  { \
407  if (this->isLoggingLevelVisible(_LVL)) \
408  { \
409  static mrpt::utils::CTicTac tim; \
410  if (tim.Tac() > _PERIOD_SECONDS) \
411  { \
412  tim.Tic(); \
413  this->logStr(_LVL, _STRING); \
414  } \
415  } \
416  } while (0)
417 
418 #define INTERNAL_MRPT_LOG_THROTTLE_STREAM(_LVL, _PERIOD_SECONDS, __CONTENTS) \
419  do \
420  { \
421  if (this->isLoggingLevelVisible(_LVL)) \
422  { \
423  static mrpt::utils::CTicTac tim; \
424  if (tim.Tac() > _PERIOD_SECONDS) \
425  { \
426  tim.Tic(); \
427  ::mrpt::utils::COutputLoggerStreamWrapper(_LVL, *this) \
428  << __CONTENTS; \
429  } \
430  } \
431  } while (0)
432 
433 #define INTERNAL_MRPT_LOG_THROTTLE_FMT( \
434  _LVL, _PERIOD_SECONDS, _FMT_STRING, ...) \
435  do \
436  { \
437  if (this->isLoggingLevelVisible(_LVL)) \
438  { \
439  static mrpt::utils::CTicTac tim; \
440  if (tim.Tac() > _PERIOD_SECONDS) \
441  { \
442  tim.Tic(); \
443  this->logFmt(_LVL, _FMT_STRING, __VA_ARGS__); \
444  } \
445  } \
446  } while (0)
447 
448 /** Use: `MRPT_LOG_DEBUG("message");` */
449 #define MRPT_LOG_DEBUG(_STRING) \
450  INTERNAL_MRPT_LOG(::mrpt::utils::LVL_DEBUG, _STRING)
451 #define MRPT_LOG_INFO(_STRING) \
452  INTERNAL_MRPT_LOG(::mrpt::utils::LVL_INFO, _STRING)
453 #define MRPT_LOG_WARN(_STRING) \
454  INTERNAL_MRPT_LOG(::mrpt::utils::LVL_WARN, _STRING)
455 #define MRPT_LOG_ERROR(_STRING) \
456  INTERNAL_MRPT_LOG(::mrpt::utils::LVL_ERROR, _STRING)
457 
458 /** Use: `MRPT_LOG_ONCE_DEBUG("once-only message");` */
459 #define MRPT_LOG_ONCE_DEBUG(_STRING) \
460  INTERNAL_MRPT_LOG_ONCE(::mrpt::utils::LVL_DEBUG, _STRING)
461 #define MRPT_LOG_ONCE_INFO(_STRING) \
462  INTERNAL_MRPT_LOG_ONCE(::mrpt::utils::LVL_INFO, _STRING)
463 #define MRPT_LOG_ONCE_WARN(_STRING) \
464  INTERNAL_MRPT_LOG_ONCE(::mrpt::utils::LVL_WARN, _STRING)
465 #define MRPT_LOG_ONCE_ERROR(_STRING) \
466  INTERNAL_MRPT_LOG_ONCE(::mrpt::utils::LVL_ERROR, _STRING)
467 
468 /** Use: `MRPT_LOG_THROTTLE_DEBUG(5.0, "message");` */
469 #define MRPT_LOG_THROTTLE_DEBUG(_PERIOD_SECONDS, _STRING) \
470  INTERNAL_MRPT_LOG_THROTTLE( \
471  ::mrpt::utils::LVL_DEBUG, _PERIOD_SECONDS, _STRING)
472 #define MRPT_LOG_THROTTLE_INFO(_PERIOD_SECONDS, _STRING) \
473  INTERNAL_MRPT_LOG_THROTTLE( \
474  ::mrpt::utils::LVL_INFO, _PERIOD_SECONDS, _STRING)
475 #define MRPT_LOG_THROTTLE_WARN(_PERIOD_SECONDS, _STRING) \
476  INTERNAL_MRPT_LOG_THROTTLE( \
477  ::mrpt::utils::LVL_WARN, _PERIOD_SECONDS, _STRING)
478 #define MRPT_LOG_THROTTLE_ERROR(_PERIOD_SECONDS, _STRING) \
479  INTERNAL_MRPT_LOG_THROTTLE( \
480  ::mrpt::utils::LVL_ERROR, _PERIOD_SECONDS, _STRING)
481 
482 /** Use: `MRPT_LOG_DEBUG_FMT("i=%u", i);` */
483 #define MRPT_LOG_DEBUG_FMT(_FMT_STRING, ...) \
484  INTERNAL_MRPT_LOG_FMT(::mrpt::utils::LVL_DEBUG, _FMT_STRING, __VA_ARGS__)
485 #define MRPT_LOG_INFO_FMT(_FMT_STRING, ...) \
486  INTERNAL_MRPT_LOG_FMT(::mrpt::utils::LVL_INFO, _FMT_STRING, __VA_ARGS__)
487 #define MRPT_LOG_WARN_FMT(_FMT_STRING, ...) \
488  INTERNAL_MRPT_LOG_FMT(::mrpt::utils::LVL_WARN, _FMT_STRING, __VA_ARGS__)
489 #define MRPT_LOG_ERROR_FMT(_FMT_STRING, ...) \
490  INTERNAL_MRPT_LOG_FMT(::mrpt::utils::LVL_ERROR, _FMT_STRING, __VA_ARGS__)
491 
492 /** Use: `MRPT_LOG_DEBUG_STREAM("Var=" << value << " foo=" << foo_var);` */
493 #define MRPT_LOG_DEBUG_STREAM(__CONTENTS) \
494  INTERNAL_MRPT_LOG_STREAM(::mrpt::utils::LVL_DEBUG, __CONTENTS)
495 #define MRPT_LOG_INFO_STREAM(__CONTENTS) \
496  INTERNAL_MRPT_LOG_STREAM(::mrpt::utils::LVL_INFO, __CONTENTS)
497 #define MRPT_LOG_WARN_STREAM(__CONTENTS) \
498  INTERNAL_MRPT_LOG_STREAM(::mrpt::utils::LVL_WARN, __CONTENTS)
499 #define MRPT_LOG_ERROR_STREAM(__CONTENTS) \
500  INTERNAL_MRPT_LOG_STREAM(::mrpt::utils::LVL_ERROR, __CONTENTS)
501 
502 /** Usage: `MRPT_LOG_THROTTLE_DEBUG_STREAM(5.0, "Var=" << value << " foo=" <<
503  * foo_var);` */
504 #define MRPT_LOG_THROTTLE_DEBUG_STREAM(_PERIOD_SECONDS, __CONTENTS) \
505  INTERNAL_MRPT_LOG_THROTTLE_STREAM( \
506  ::mrpt::utils::LVL_DEBUG, _PERIOD_SECONDS, __CONTENTS)
507 #define MRPT_LOG_THROTTLE_INFO_STREAM(_PERIOD_SECONDS, __CONTENTS) \
508  INTERNAL_MRPT_LOG_THROTTLE_STREAM( \
509  ::mrpt::utils::LVL_INFO, _PERIOD_SECONDS, __CONTENTS)
510 #define MRPT_LOG_THROTTLE_WARN_STREAM(_PERIOD_SECONDS, __CONTENTS) \
511  INTERNAL_MRPT_LOG_THROTTLE_STREAM( \
512  ::mrpt::utils::LVL_WARN, _PERIOD_SECONDS, __CONTENTS)
513 #define MRPT_LOG_THROTTLE_ERROR_STREAM(_PERIOD_SECONDS, __CONTENTS) \
514  INTERNAL_MRPT_LOG_THROTTLE_STREAM( \
515  ::mrpt::utils::LVL_ERROR, _PERIOD_SECONDS, __CONTENTS)
516 
517 /** Usage: `MRPT_LOG_THROTTLE_DEBUG_FMT(5.0, "i=%u", i);` */
518 #define MRPT_LOG_THROTTLE_DEBUG_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \
519  INTERNAL_MRPT_LOG_THROTTLE_FMT( \
520  ::mrpt::utils::LVL_DEBUG, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__)
521 #define MRPT_LOG_THROTTLE_INFO_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \
522  INTERNAL_MRPT_LOG_THROTTLE_FMT( \
523  ::mrpt::utils::LVL_INFO, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__)
524 #define MRPT_LOG_THROTTLE_WARN_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \
525  INTERNAL_MRPT_LOG_THROTTLE_FMT( \
526  ::mrpt::utils::LVL_WARN, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__)
527 #define MRPT_LOG_THROTTLE_ERROR_FMT(_PERIOD_SECONDS, _FMT_STRING, ...) \
528  INTERNAL_MRPT_LOG_THROTTLE_FMT( \
529  ::mrpt::utils::LVL_ERROR, _PERIOD_SECONDS, _FMT_STRING, __VA_ARGS__)
530 
531 #ifdef _DEBUG
532 #define DEFAULT_LOGLVL_MRPT_UNSCOPED ::mrpt::utils::LVL_DEBUG
533 #else
534 #define DEFAULT_LOGLVL_MRPT_UNSCOPED ::mrpt::utils::LVL_DEBUG
535 #endif
536 
537 /** For calling any `MRPT_LOG_*()` macro from outside of an object inherited
538  * from COutputLogger.
539  * Debug level is `DEBUG` if build with `_DEBUG` preprocessor flag, `INFO`
540  * otherwise.
541  * Use:
542  * \code
543  * MRPT_UNSCOPED_LOGGER_START;
544  * MRPT_LOG_WARN("blah");
545  * MRPT_LOG_ERROR_STREAM("error: " << strval);
546  * MRPT_UNSCOPED_LOGGER_END;
547  */
548 #define MRPT_UNSCOPED_LOGGER_START \
549  do \
550  { \
551  struct dummy_logger_ : public mrpt::utils::COutputLogger \
552  { \
553  dummy_logger_() : mrpt::utils::COutputLogger("MRPT_log") \
554  { \
555  this->setMinLoggingLevel(DEFAULT_LOGLVL_MRPT_UNSCOPED); \
556  } \
557  void usercode() \
558  { \
559  do \
560  { \
561  } while (0) \
562 // Here comes the user code, which is run in the ctor, and will call the object
563 // log methods.
564 
565 #define MRPT_UNSCOPED_LOGGER_END \
566  } \
567  } \
568  ; \
569  static dummy_logger_ tmp_obj; \
570  tmp_obj.usercode(); \
571  } \
572  while (0)
573 }
574 // Specializations MUST occur at the same namespace:
575 namespace utils
576 {
577 template <>
578 struct TEnumTypeFiller<mrpt::utils::VerbosityLevel>
579 {
580  typedef mrpt::utils::VerbosityLevel enum_t;
581  static void fill(bimap<enum_t, std::string>& m_map)
582  {
583  using namespace mrpt::utils;
584  m_map.insert(LVL_DEBUG, "DEBUG");
585  m_map.insert(LVL_DEBUG, "LVL_DEBUG");
586  m_map.insert(LVL_INFO, "INFO");
587  m_map.insert(LVL_INFO, "LVL_INFO");
588  m_map.insert(LVL_WARN, "WARN");
589  m_map.insert(LVL_WARN, "LVL_WARN");
590  m_map.insert(LVL_ERROR, "ERROR");
591  m_map.insert(LVL_ERROR, "LVL_ERROR");
592  }
593 };
594 } // End of namespace
595 }
596 #endif /* end of include guard: COUTPUTLOGGER_H */
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:32
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
static void fill(mrpt::utils::bimap< enum_t, std::string > &m_map)
STL namespace.
bool operator==(const mrpt::utils::TCamera &a, const mrpt::utils::TCamera &b)
Definition: TCamera.cpp:204
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
int val
Definition: mrpt_jpeglib.h:955
TConsoleColor
For use in setConsoleColor.
Definition: os.h:178
CStream & operator<<(mrpt::utils::CStream &s, const char *a)
Definition: CStream.cpp:123
GLsizei const GLchar ** string
Definition: glext.h:4101
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLboolean reset
Definition: glext.h:3582
GLint level
Definition: glext.h:3600
GLuint const GLchar * name
Definition: glext.h:4054
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
bool operator<(const TMatchingPair &a, const TMatchingPair &b)
A comparison operator, for sorting lists of TMatchingPair&#39;s, first order by this_idx, if equals, by other_idx.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019