|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
Singleton logger (instance()) with a minimum level and a list of handlers; log() passes each record to every handler. More...
#include <Logger.hh>
Public Types | |
| enum | LEVEL { DEBUG =0 , TRACE , INFO , WARNING , ERROR , FATAL , NOLOG , LAST_LEVEL =NOLOG , NUM_LEVELS =LAST_LEVEL+1 } |
| Message levels; logging(sev) is true when sev >= the current level. More... | |
Public Member Functions | |
| void | logmsg (const LogStream &ss, const LEVEL &sev=DEBUG) |
| Increment the record counter and print the counter (4 digits), the 3-letter level and the text of ss to stdout; for levels above INFO also print the source file and line. | |
| void | loggerInfo (std::ostream &out) |
| Write the start timestamp, current level, log name and number of levels to out. | |
| const std::string & | tstampStart () const |
| Return the timestamp taken when the logger was created (format Y-m-d H:M:S. | |
| void | setLogname (const std::string &logname) |
| Set the logger name shown by loggerInfo(). | |
| void | setLevel (const LEVEL &level) |
| Set the minimum level used by logging(). | |
| bool | logging (const LEVEL &sev) |
| Return true if sev >= the current level. | |
| const char * | levelToName (const LEVEL &level) |
| Return the 3-letter name of level (e.g. | |
| LEVEL | name_to_level (const std::string &name) |
| Return the LEVEL for a full level name ("DEBUG", "TRACE", "INFO", "WARNING", "ERROR", "FATAL" or "NOLOG"); throws std::out_of_range for any other string. | |
| void | log (const LogRecord &rec) |
| Increment the record counter and pass rec to every handler. | |
| const unsigned | counter () |
| Return the number of records counted so far. | |
| void | setLogger (const LEVEL &level=DEBUG, const std::string &timefmt="%H:%M:%S.%f") |
| Set the level and the time format of every handler's formatter. | |
| void | addHandler (LogHandler *handler) |
| add a handler for the messages, takes ownership of the object | |
| void | setTimeFormat (const std::string &timefmt="%Y-%m-%d %H:%M:%S.%f") |
| Set the time format of every handler's formatter (a strftime format in which f is replaced by milliseconds). | |
Static Public Member Functions | |
| static Logger * | instance () |
| Return the singleton, creating it on the first call (no locking). | |
Public Attributes | |
| char * | LEVELCN [NUM_LEVELS] |
| Full level names ("DEBUG" ... "NOLOG"), filled by the constructor. | |
| char * | LEVELC3 [NUM_LEVELS] |
| Three-letter level names ("DBG", "TRC", "INF", "WRN", "ERR", "FTL", "NLG"), returned by levelToName(). | |
| char | LEVELC1 [NUM_LEVELS] |
| One-letter level codes ('D', 'T', 'I', 'W', 'E', 'F', 'N'). | |
Singleton logger (instance()) with a minimum level and a list of handlers; log() passes each record to every handler.
The instance starts at level INFO with one LogHandlerStdStreams.
|
inline |
add a handler for the messages, takes ownership of the object
|
inline |
Return the number of records counted so far.
|
inlinestatic |
Return the singleton, creating it on the first call (no locking).
| const char * Logger::Logger::levelToName | ( | const LEVEL & | level | ) |
Return the 3-letter name of level (e.g.
"WRN").
| void Logger::Logger::log | ( | const LogRecord & | rec | ) |
Increment the record counter and pass rec to every handler.
| void Logger::Logger::loggerInfo | ( | std::ostream & | out | ) |
Write the start timestamp, current level, log name and number of levels to out.
|
inline |
Return true if sev >= the current level.
Increment the record counter and print the counter (4 digits), the 3-letter level and the text of ss to stdout; for levels above INFO also print the source file and line.
| LEVEL Logger::Logger::name_to_level | ( | const std::string & | name | ) |
Return the LEVEL for a full level name ("DEBUG", "TRACE", "INFO", "WARNING", "ERROR", "FATAL" or "NOLOG"); throws std::out_of_range for any other string.
|
inline |
Set the minimum level used by logging().
| void Logger::Logger::setLogger | ( | const LEVEL & | level = DEBUG, |
| const std::string & | timefmt = "%H:%M:%S.%f" |
||
| ) |
Set the level and the time format of every handler's formatter.
|
inline |
Set the logger name shown by loggerInfo().
| void Logger::Logger::setTimeFormat | ( | const std::string & | timefmt = "%Y-%m-%d %H:%M:%S.%f" | ) |
Set the time format of every handler's formatter (a strftime format in which f is replaced by milliseconds).
|
inline |
Return the timestamp taken when the logger was created (format Y-m-d H:M:S.
f, f being milliseconds).
| char Logger::Logger::LEVELC1[NUM_LEVELS] |
One-letter level codes ('D', 'T', 'I', 'W', 'E', 'F', 'N').
| char* Logger::Logger::LEVELC3[NUM_LEVELS] |
Three-letter level names ("DBG", "TRC", "INF", "WRN", "ERR", "FTL", "NLG"), returned by levelToName().
| char* Logger::Logger::LEVELCN[NUM_LEVELS] |
Full level names ("DEBUG" ... "NOLOG"), filled by the constructor.