RSC
0.16.0
|
A simple logger that uses cout and cerr for logging. More...
#include <ConsoleLogger.h>
Public Member Functions | |
ConsoleLogger (const std::string &name) | |
Creates a new logger with the given name and level INFO. More... | |
ConsoleLogger (const std::string &name, const Level &level) | |
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 |
Private Member Functions | |
std::ostream & | printHeader (std::ostream &stream, const Level &level) |
Prints a generic header for this logger to the stream. More... | |
Private 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 42 of file ConsoleLogger.h.
rsc::logging::ConsoleLogger::ConsoleLogger | ( | const std::string & | name | ) |
Creates a new logger with the given name and level INFO.
name | name of the logger |
Definition at line 38 of file ConsoleLogger.cpp.
rsc::logging::ConsoleLogger::ConsoleLogger | ( | const std::string & | name, |
const Level & | level | ||
) |
|
virtual |
Definition at line 47 of file ConsoleLogger.cpp.
|
virtual |
Returns the currently defined level of the logger.
Implements rsc::logging::Logger.
Definition at line 50 of file ConsoleLogger.cpp.
|
virtual |
Returns the hierarchical name of the logger.
Implements rsc::logging::Logger.
Definition at line 60 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, and printHeader().
|
private |
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 70 of file ConsoleLogger.cpp.
References rsc::misc::currentTimeMillis().
Referenced by log().
void rsc::logging::ConsoleLogger::setLevel | ( | const Level & | level | ) |
Definition at line 55 of file ConsoleLogger.cpp.
|
virtual |
Sets the name of the logger.
name | new name |
Implements rsc::logging::Logger.
Definition at line 65 of file ConsoleLogger.cpp.
|
private |
Definition at line 74 of file ConsoleLogger.h.
Referenced by ConsoleLogger(), getLevel(), and setLevel().
|
mutableprivate |
Definition at line 76 of file ConsoleLogger.h.
Referenced by getLevel(), getName(), log(), setLevel(), and setName().
|
private |
Definition at line 73 of file ConsoleLogger.h.
Referenced by ConsoleLogger(), getName(), and setName().