|
MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
|
Simple singleton logging class. More...
#include <Logger.hh>
Classes | |
| class | Message |
| Temporary object used for forming logger messages. More... | |
Public Types | |
| enum class | LogLevel { TRACE = MARLEY_LOGGER_LEVEL_TRACE , DEBUG = MARLEY_LOGGER_LEVEL_DEBUG , INFO = MARLEY_LOGGER_LEVEL_INFO , NOTICE = MARLEY_LOGGER_LEVEL_NOTICE , WARN = MARLEY_LOGGER_LEVEL_WARN , ERROR = MARLEY_LOGGER_LEVEL_ERROR , FATAL = MARLEY_LOGGER_LEVEL_FATAL } |
| Defines the logging levels recognized by the marley::Logger. More... | |
Public Member Functions | |
| Logger () | |
| Create the singleton Logger. | |
| Logger (const Logger &)=delete | |
| Deleted copy constructor. | |
| Logger (Logger &&)=delete | |
| Deleted move constructor. | |
| LogLevel | category_level (const std::string &category) |
| Looks up the severity setting for the input category, including inheritance from the hierarchy. | |
| void | configure (const marley::JSON &json) |
| Initialize the Logger using settings expressed as a JSON object. | |
| bool | has_stream (const std::ostream &stream) const |
| Returns true if stream is already registered with the Logger, or false otherwise. | |
| Message | log (LogLevel lev, const std::string &category="") |
| Prepare the Logger to receive a log message via the << stream operator. | |
| Logger & | operator= (const Logger &)=delete |
| Deleted copy assignment operator. | |
| Logger & | operator= (Logger &&)=delete |
| Deleted move assignment operator. | |
| bool | should_emit (const std::string &category, LogLevel lev) |
| Returns whether the logger should emit a message for the given category and level. | |
Static Public Member Functions | |
| static Logger & | Instance () |
| Get the singleton instance of the Logger class. | |
| static LogLevel | string_to_loglevel (const std::string &str) |
Simple singleton logging class.
This class is based on code found here.
|
strong |
Defines the logging levels recognized by the marley::Logger.
Note that we tie the numerical values of the levels to the previously-defined pre-processor macros to ensure consistency. The levels appear in increasing numerical order (increasing severity).
Definition at line 102 of file Logger.hh.
| marley::Logger::Logger | ( | ) |
Create the singleton Logger.
Definition at line 213 of file Logger.cc.
References configure().
Referenced by Logger(), Logger(), Instance(), operator=(), and operator=().
| marley::Logger::LogLevel marley::Logger::category_level | ( | const std::string & | category | ) |
Looks up the severity setting for the input category, including inheritance from the hierarchy.
Definition at line 333 of file Logger.cc.
Referenced by should_emit().
| void marley::Logger::configure | ( | const marley::JSON & | json | ) |
Initialize the Logger using settings expressed as a JSON object.
Definition at line 88 of file Logger.cc.
Referenced by Logger().
| bool marley::Logger::has_stream | ( | const std::ostream & | stream | ) | const |
|
static |
| marley::Logger::Message marley::Logger::log | ( | LogLevel | lev, |
| const std::string & | category = "" ) |
Prepare the Logger to receive a log message via the << stream operator.
| lev | marley::Logger::LogLevel of the incoming message |
| category | Named category of the incoming message |
Definition at line 294 of file Logger.cc.
References should_emit().
|
inline |
Returns whether the logger should emit a message for the given category and level.
Definition at line 337 of file Logger.hh.
References category_level().
Referenced by log().
|
static |
Definition at line 47 of file Logger.cc.