Go to the documentation of this file.
18 #ifndef _GAZEBO_CONSOLE_HH_
19 #define _GAZEBO_CONSOLE_HH_
26 #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
27 # include <boost/thread.hpp>
41 #define gzmsg (gazebo::common::Console::msg())
44 #define gzdbg (gazebo::common::Console::dbg(__FILE__, __LINE__))
47 #define gzwarn (gazebo::common::Console::warn(__FILE__, __LINE__))
50 #define gzerr (gazebo::common::Console::err(__FILE__, __LINE__))
53 #define gzlog (gazebo::common::Console::log())
61 #define gzLogInit(_prefix, _str) \
62 (gazebo::common::Console::log.Init(_prefix, _str))
66 #define gzLogDirectory() (gazebo::common::Console::log.GetLogDirectory())
75 public:
explicit FileLogger(
const std::string &_filename =
"");
85 public:
void Init(
const std::string &_prefix,
86 const std::string &_filename);
99 const std::string &_file,
int _line);
108 private:
static std::string GetMasterPort();
111 protected:
class Buffer :
public std::stringbuf
115 public:
explicit Buffer(
const std::string &_filename);
131 private: std::string logDirectory;
136 class GZ_COMMON_VISIBLE
Logger :
public std::ostream
167 const std::string &_file,
int _line);
170 protected:
class Buffer :
public std::stringbuf
199 private: std::string prefix;
231 private:
static bool quiet;
static Logger dbg
Global instance of the debug logger.
Definition: Console.hh:222
Logger(const std::string &_prefix, int _color, LogType _type)
Constructor.
std::string GetLogDirectory() const
Get the full path of the directory where all the log files are stored.
virtual Logger & operator()(const std::string &_file, int _line)
Output a filename and line number, then return a reference to the logger.
LogType
Output destination type.
Definition: Console.hh:141
Forward declarations for the common classes.
Definition: Animation.hh:27
@ STDOUT
Output to stdout.
Definition: Console.hh:143
Buffer(LogType _type, int _color)
Constructor.
virtual FileLogger & operator()(const std::string &_file, int _line)
Output a filename and line number, then return a reference to the logger.
common
Definition: FuelModelDatabase.hh:37
static Logger msg
Global instance of the message logger.
Definition: Console.hh:216
int color
Color for the output.
Definition: Console.hh:196
int color
ANSI color code using Select Graphic Rendition parameters (SGR).
Definition: Console.hh:192
virtual int sync()
Sync the stream (output the string buffer contents).
Buffer(const std::string &_filename)
Constructor.
virtual ~Buffer()
Destructor.
virtual ~Logger()
Destructor.
LogType type
Destination type for the messages.
Definition: Console.hh:187
String buffer for the file logger.
Definition: Console.hh:112
static void SetQuiet(bool _q)
Set quiet output.
void Init(const std::string &_prefix, const std::string &_filename)
Initialize the file logger.
Terminal logger.
Definition: Console.hh:137
@ STDERR
Output to stderr.
Definition: Console.hh:145
virtual int sync()
Sync the stream (output the string buffer contents).
static FileLogger log
Global instance of the file logger.
Definition: Console.hh:228
virtual Logger & operator()()
Access operator.
String buffer for the base logger.
Definition: Console.hh:171
std::ofstream * stream
Stream to output information into.
Definition: Console.hh:126
Container for loggers, and global logging options (such as verbose vs. quiet output).
Definition: Console.hh:206
A logger that outputs messages to a file.
Definition: Console.hh:71
virtual FileLogger & operator()()
Output a filename and line number, then return a reference to the logger.
virtual ~Buffer()
Destructor.
static bool GetQuiet()
Get whether quiet output is set.
virtual ~FileLogger()
Destructor.
FileLogger(const std::string &_filename="")
Constructor.
static Logger err
Global instance of the error logger.
Definition: Console.hh:219
static Logger warn
Global instance of the warning logger.
Definition: Console.hh:225