lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Logger.hh File Reference

Declares the psalg logging classes (Logger singleton, LogStream, LogRecord, LogFormatter, LogHandler, LogHandlerStdStreams) and the MSG, MSGLOG and MSGSTREAM macros. More...

#include <vector>
#include <string>
#include <sstream>

Classes

class  Logger::Logger
 Singleton logger (instance()) with a minimum level and a list of handlers; log() passes each record to every handler. More...
 
class  Logger::LogStream
 String stream that collects one message and, when destroyed, passes it to the singleton as a LogRecord. More...
 
class  Logger::LogRecord
 One log message: logger name (held by reference), level, source file and line, and a pointer to the stream buffer with the text. More...
 
class  Logger::LogFormatter
 Formats a LogRecord as: the time (if a time format is set), the 4-digit record counter, the 3-letter level, for levels other than INFO the file name (without directories), a colon and the line number, and the message text. More...
 
class  Logger::LogHandler
 Abstract handler that writes LogRecords with a LogFormatter it owns (a default one is created on first use if none was set). More...
 
class  Logger::LogHandlerStdStreams
 Handler that formats records of level INFO or lower to stdout and higher levels to stderr, each followed by std::endl. More...
 

Namespaces

namespace  Logger
 

Macros

#define LL   Logger::Logger
 Shortcut for Logger::Logger.
 
#define LOGGER   (*LL::instance())
 The singleton logger, (*Logger::Logger::instance()).
 
#define __MACROPARS   __FILE__,__LINE__
 Expands to FILE,LINE.
 
#define MSGLOG(logger, sev, msg)
 If level sev is enabled, stream msg into a LogStream with logger name logger and the current file and line; it is logged when the statement ends.
 
#define MSG(sev, msg)
 If level sev is enabled, stream msg into a LogStream with an empty logger name and the current file and line; it is logged when the statement ends.
 
#define MSGSTREAM(sev, strm)
 If level sev is enabled, run the following statement or block once with a LogStream named strm (empty logger name), then log what was written to it.
 

Detailed Description

Declares the psalg logging classes (Logger singleton, LogStream, LogRecord, LogFormatter, LogHandler, LogHandlerStdStreams) and the MSG, MSGLOG and MSGSTREAM macros.

Macro Definition Documentation

◆ __MACROPARS

#define __MACROPARS   __FILE__,__LINE__

Expands to FILE,LINE.

◆ LL

#define LL   Logger::Logger

Shortcut for Logger::Logger.

◆ LOGGER

#define LOGGER   (*LL::instance())

The singleton logger, (*Logger::Logger::instance()).

◆ MSG

#define MSG (   sev,
  msg 
)
Value:
if (LOGGER.logging(LL::sev)){ \
Logger::LogStream _log_stream(std::string(),LL::sev,__MACROPARS); _log_stream << msg; \
}
#define __MACROPARS
Expands to FILE,LINE.
Definition Logger.hh:334
#define LOGGER
The singleton logger, (*Logger::Logger::instance()).
Definition Logger.hh:332
String stream that collects one message and, when destroyed, passes it to the singleton as a LogRecor...
Definition Logger.hh:142

If level sev is enabled, stream msg into a LogStream with an empty logger name and the current file and line; it is logged when the statement ends.

◆ MSGLOG

#define MSGLOG (   logger,
  sev,
  msg 
)
Value:
if (LOGGER.logging(LL::sev)){ \
Logger::LogStream _log_stream(logger,LL::sev,__MACROPARS); _log_stream.logger_ostream() << msg; \
}

If level sev is enabled, stream msg into a LogStream with logger name logger and the current file and line; it is logged when the statement ends.

◆ MSGSTREAM

#define MSGSTREAM (   sev,
  strm 
)
Value:
if (LOGGER.logging(LL::sev)) \
for(Logger::LogStream strm(std::string(),LL::sev,__MACROPARS); strm.ok(); strm.finish())
bool ok() const
get the state of the stream
Definition Logger.hh:160

If level sev is enabled, run the following statement or block once with a LogStream named strm (empty logger name), then log what was written to it.