RSC
0.19.0
|
A simple logger that uses cout and cerr for logging. More...
#include <ConsoleLogger.h>
Public Member Functions | |
ConsoleLogger (const std::string &name, const Level &level=LEVEL_INFO) | |
Creates a new logger with the given name and level INFO. More... | |
virtual | ~ConsoleLogger () |
Level | getLevel () const |
Returns the currently defined level of the logger. More... | |
void | setLevel (const Level &level) |
std::string | getName () const |
Returns the hierarchical name of the logger. More... | |
void | setName (const std::string &name) |
Sets the name of the logger. More... | |
void | log (const Level &level, const std::string &msg) |
Public Member Functions inherited from rsc::logging::Logger | |
virtual | ~Logger () |
virtual void | log (const Level &level, const std::string &msg)=0 |
Logs a message with the given level if it is enabled. More... | |
virtual void | setLevel (const Level &level)=0 |
Defines the level of the logger. More... | |
virtual void | trace (const std::string &msg) |
Logs a message with trace logging level if this level is enabled. More... | |
virtual void | debug (const std::string &msg) |
Logs a message with debug logging level if this level is enabled. More... | |
virtual void | info (const std::string &msg) |
Logs a message with info logging level if this level is enabled. More... | |
virtual void | warn (const std::string &msg) |
Logs a message with warn logging level if this level is enabled. More... | |
virtual void | error (const std::string &msg) |
Logs a message with error logging level if this level is enabled. More... | |
virtual void | fatal (const std::string &msg) |
Logs a message with fatal logging level if this level is enabled. More... | |
virtual bool | isTraceEnabled () const |
virtual bool | isDebugEnabled () const |
virtual bool | isInfoEnabled () const |
virtual bool | isWarnEnabled () const |
virtual bool | isErrorEnabled () const |
virtual bool | isFatalEnabled () const |
virtual bool | isEnabledFor (const Level &level) const |
Protected Member Functions | |
virtual std::ostream & | printHeader (std::ostream &stream, const Level &level) |
Prints a generic header for this logger to the stream. More... | |
virtual std::ostream & | printBody (std::ostream &stream, const Level &level, const std::string &msg) |
Print the msg as the body of the log message. More... | |
Protected Attributes | |
std::string | name |
Level | level |
boost::recursive_mutex | mutex |
Additional Inherited Members | |
Public Types inherited from rsc::logging::Logger | |
enum | Level { LEVEL_ALL = 0x11111111, LEVEL_TRACE = 60, LEVEL_DEBUG = 50, LEVEL_INFO = 40, LEVEL_WARN = 30, LEVEL_ERROR = 20, LEVEL_FATAL = 10, LEVEL_OFF = 0 } |
Possible logging levels. More... | |
Static Public Member Functions inherited from rsc::logging::Logger | |
static LoggerPtr | getLogger (const std::string &name) |
Returns a logger for the given name. More... | |
A simple logger that uses cout and cerr for logging.
Definition at line 45 of file ConsoleLogger.h.
rsc::logging::ConsoleLogger::ConsoleLogger | ( | const std::string & | name, |
const Level & | level = LEVEL_INFO |
||
) |
Creates a new logger with the given name and level INFO.
name | name of the logger |
Definition at line 37 of file ConsoleLogger.cpp.
|
virtual |
Definition at line 41 of file ConsoleLogger.cpp.
|
virtual |
Returns the currently defined level of the logger.
Implements rsc::logging::Logger.
Definition at line 44 of file ConsoleLogger.cpp.
|
virtual |
Returns the hierarchical name of the logger.
Implements rsc::logging::Logger.
Definition at line 54 of file ConsoleLogger.cpp.
void rsc::logging::ConsoleLogger::log | ( | const Level & | level, |
const std::string & | msg | ||
) |
Definition at line 75 of file ConsoleLogger.cpp.
References rsc::logging::Logger::isEnabledFor(), mutex, printBody(), and printHeader().
|
protectedvirtual |
Print the msg as the body of the log message.
Acquire the lock before calling this method.
stream | Stream to print to |
level | The level of the log message |
msg | The body string of the log message |
Definition at line 69 of file ConsoleLogger.cpp.
Referenced by log().
|
protectedvirtual |
Prints a generic header for this logger to the stream.
Acquire the lock before calling this method.
stream | stream to print on |
level | the level of the header to generate |
Definition at line 64 of file ConsoleLogger.cpp.
References rsc::misc::currentTimeMillis(), and name.
Referenced by log().
void rsc::logging::ConsoleLogger::setLevel | ( | const Level & | level | ) |
Definition at line 49 of file ConsoleLogger.cpp.
|
virtual |
Sets the name of the logger.
name | new name |
Implements rsc::logging::Logger.
Definition at line 59 of file ConsoleLogger.cpp.
|
protected |
Definition at line 90 of file ConsoleLogger.h.
Referenced by getLevel(), and setLevel().
|
mutableprotected |
Definition at line 92 of file ConsoleLogger.h.
Referenced by getLevel(), getName(), log(), setLevel(), and setName().
|
protected |
Definition at line 89 of file ConsoleLogger.h.
Referenced by getName(), rsc::logging::SGRConsoleLogger::printHeader(), printHeader(), and setName().