libmoost
|
handles scoped logging gracefully across the whole project. global_scoped_logger takes a scoped_logger and makes it available across the whole project without having to pass the object around. global_scoped_logger is thread safe because each object is thread specific. In order to be able to use global_scoped_logger you need to define the scope where the logging will operate: More...
#include <global_scoped_logger.h>
Public Member Functions | |
global_scoped_logger (const std::string &name) | |
template<typename TTimer > | |
global_scoped_logger (const std::string &name, TTimer &start) | |
~global_scoped_logger () | |
Private Attributes | |
global_scoped_logger_t & | m_pScopedLogging |
handles scoped logging gracefully across the whole project. global_scoped_logger takes a scoped_logger and makes it available across the whole project without having to pass the object around. global_scoped_logger is thread safe because each object is thread specific. In order to be able to use global_scoped_logger you need to define the scope where the logging will operate:
void someFunction() { MLOG_SCOPED_GLOBAL_FUNC_INIT; // alternatively one can specify the name with: // MLOG_SCOPED_GLOBAL_NAMED_INIT("someName"); // now it's time to get the logger MLOG_SCOPED_GLOBAL_GET_LOGGER(logger); MLOG(MLOG_LEVEL_INFO, logger, "log this: " << 944534634578UL); }
Now, this alone would not be very useful. The true power of global_scoped_logger is that you have access of the logger everywhere in your code without having to pass it around! Let's say you defined a few functions before "someFunction()":
void foo() { MLOG_SCOPED_GLOBAL_GET_LOGGER(logger); MLOG(MLOG_LEVEL_INFO, logger, "I am in foo!"); } void bar() { foo(); // nothing needs to be passed here }
Definition at line 82 of file global_scoped_logger.h.
moost::logging::global_scoped_logger::global_scoped_logger | ( | const std::string & | name | ) | [inline] |
Definition at line 86 of file global_scoped_logger.h.
moost::logging::global_scoped_logger::global_scoped_logger | ( | const std::string & | name, |
TTimer & | start | ||
) | [inline] |
Definition at line 91 of file global_scoped_logger.h.
Definition at line 95 of file global_scoped_logger.h.
Definition at line 100 of file global_scoped_logger.h.