Drake
text_logging.h File Reference

Detailed Description

This is the entry point for all text logging within Drake.

Once you've included this file, the suggested ways you should write log messages include:

  drake::log()->trace("Some trace message: {} {}", something, some_other);

Similarly, it provides:

  drake::log()->debug(...);
  drake::log()->info(...);
  drake::log()->warn(...);
  drake::log()->error(...);
  drake::log()->critical(...);

If you want to log objects that are expensive to serialize, these macros will not be compiled if debugging is turned off (-DNDEBUG is set):

  SPDLOG_LOGGER_TRACE(drake::log(), "message: {}", something_conditionally_compiled);
  SPDLOG_LOGGER_DEBUG(drake::log(), "message: {}", something_conditionally_compiled);

The format string syntax is fmtlib; see http://fmtlib.net/5.3.0/syntax.html. In particular, any class that overloads operator<< for ostream can be printed without any special handling.

#include <string>
#include "drake/common/drake_copyable.h"
Include dependency graph for text_logging.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  Warn
 When constructed, logs a message (at "warn" severity); the destructor is guaranteed to be trivial. More...
 

Namespaces

 drake
 
 drake::logging
 

Typedefs

using logger = spdlog::logger
 The drake::logging::logger class provides text logging methods. More...
 

Functions

logging::logger * log ()
 Retrieve an instance of a logger to use for logging; for example: More...
 
sink * get_dist_sink ()
 (Advanced) Retrieves the default sink for all Drake logs. More...
 
std::string set_log_level (const std::string &level)
 Invokes drake::log()->set_level(level). More...
 

Variables

constexpr bool kHaveSpdlog = true
 True only if spdlog is enabled in this build. More...