![]() |
Scarab
v1.5.2
Project 8 C++ Utility Library
|
#include <logger.hh>
Classes | |
struct | Location |
struct | Private |
Public Types | |
enum | ELevel { eTrace = 0, eDebug = 1, eInfo = 2, eProg = 3, eWarn = 4, eError = 5, eFatal = 6 } |
Public Member Functions | |
logger (const char *name=0) | |
logger (const std::string &name) | |
virtual | ~logger () |
bool | IsLevelEnabled (ELevel level) const |
void | SetLevel (ELevel level) const |
void | SetGlobalLevel (ELevel level) const |
void | Log (ELevel level, const std::string &message, const Location &loc=Location()) |
void | LogTrace (const std::string &message, const Location &loc=Location()) |
void | LogDebug (const std::string &message, const Location &loc=Location()) |
void | LogInfo (const std::string &message, const Location &loc=Location()) |
void | LogProg (const std::string &message, const Location &loc=Location()) |
void | LogWarn (const std::string &message, const Location &loc=Location()) |
void | LogError (const std::string &message, const Location &loc=Location()) |
void | LogFatal (const std::string &message, const Location &loc=Location()) |
Static Public Member Functions | |
static logger & | GetRootLogger () |
static void | SetColored (bool flag) |
static void | SetOutStream (std::ostream *stream) |
static void | SetErrStream (std::ostream *stream) |
Private Attributes | |
Private * | fPrivate |
The scarab logger.
The usage and syntax is inspired by log4j. logger itself uses the log4cxx library if it was available on the system during compiling, otherwise it falls back to std::stream.
The logger output can be configured in a file specified with the environment variable LOGGER_CONFIGURATION (by default log4cxx.properties in the config directory).
In most cases the following macro can be used to instantiate a Logger in your code:
LOGGER(myLogger, "loggerName");
This is equivalent to:
static mantis::logger myLogger("loggerName");
For logging the following macros can be used. The source code location will then automatically included in the output:
LOG(myLogger, level, "message"); LTRACE(myLogger, "message"); LDEBUG(myLogger, "message"); LINFO(myLogger, "message"); LPROG(myLogger, "message"); LWARN(myLogger, "message"); LERROR(myLogger, "message"); FATAL(myLogger, "message");
ASSERT(myLogger, assertion, "message");
LOG_ONCE(myLogger, level, "message"); TRACE_ONCE(myLogger, "message"); DEBUG_ONCE(myLogger, "message"); INFO_ONCE(myLogger, "message"); PROG_ONCE(myLogger, "message"); WARN_ONCE(myLogger, "message"); ERROR_ONCE(myLogger, "message"); FATAL_ONCE(myLogger, "message");
enum ELevel |
logger | ( | const char * | name = 0 | ) |
logger | ( | const std::string & | name | ) |
bool IsLevelEnabled | ( | ELevel | level | ) | const |
Log a message with the specified level. Use the macro LOG(logger, level, message).
level | The log level. |
message | The message. |
loc | Source code location (set automatically by the corresponding macro). |
Log a message at DEBUG level. Use the macro LDEBUG(logger, message).
message | The message. |
loc | Source code location (set automatically by the corresponding macro). |
Log a message at ERROR level. Use the macro LERROR(logger, message).
message | The message. |
loc | Source code location (set automatically by the corresponding macro). |
Log a message at INFO level. Use the macro LINFO(logger, message).
message | The message. |
loc | Source code location (set automatically by the corresponding macro). |
Log a message at TRACE level. Use the macro LTRACE(logger, message).
message | The message. |
loc | Source code location (set automatically by the corresponding macro). |
Log a message at WARN level. Use the macro LWARN(logger, message).
message | The message. |
loc | Source code location (set automatically by the corresponding macro). |
|
static |
|
static |
void SetGlobalLevel | ( | ELevel | level | ) | const |
void SetLevel | ( | ELevel | level | ) | const |
|
static |