MARLEY (Model of Argon Reaction Low Energy Yields)
v1.2.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
|
Simple singleton logging class. More...
#include <Logger.hh>
Public Types | |
enum class | LogLevel { DISABLED , ERROR , WARNING , INFO , DEBUG } |
Defines the logging levels recognized by the marley::Logger. More... | |
Public Member Functions | |
Logger (const Logger &)=delete | |
Deleted copy constructor. | |
Logger (Logger &&)=delete | |
Deleted move constructor. | |
void | add_stream (std::ostream &stream, LogLevel level=LogLevel::WARNING) |
Add a std::ostream to the vector of streams that will receive Logger output. More... | |
void | add_stream (std::shared_ptr< std::ostream > stream, LogLevel level=LogLevel::WARNING) |
Add a std::ostream to the vector of streams that will receive Logger output. More... | |
void | clear_streams () |
Clear the vector of streams that receive Logger output. | |
void | disable () |
Disable the Logger. | |
void | enable (bool log_enabled=true) |
Enable or disable the Logger. More... | |
void | flush () |
Flush all output streams associated with the Logger. | |
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=LogLevel::WARNING) |
Prepare the Logger to receive a log message via the << stream operator. More... | |
void | newline () |
Send a newline character to all output streams ignoring logging level settings. | |
Logger & | operator= (const Logger &)=delete |
Deleted copy assignment operator. | |
Logger & | operator= (Logger &&)=delete |
Deleted move assignment operator. | |
Static Public Member Functions | |
static Logger & | Instance () |
Get the singleton instance of the Logger class. | |
Simple singleton logging class.
This class is based on code found here.
|
strong |
Defines the logging levels recognized by the marley::Logger.
Note that C++ automatically assigns ascending values to the enum class members (which have an underlying integral type) in the order that they are written in the definition, so ERROR < WARNING < INFO < DEBUG.
void marley::Logger::add_stream | ( | std::ostream & | stream, |
LogLevel | level = LogLevel::WARNING |
||
) |
Add a std::ostream to the vector of streams that will receive Logger output.
void marley::Logger::add_stream | ( | std::shared_ptr< std::ostream > | stream, |
LogLevel | level = LogLevel::WARNING |
||
) |
Add a std::ostream to the vector of streams that will receive Logger output.
void marley::Logger::enable | ( | bool | log_enabled = true | ) |
marley::Logger::Message marley::Logger::log | ( | LogLevel | lev = LogLevel::WARNING | ) |
Prepare the Logger to receive a log message via the << stream operator.
lev | marley::Logger::LogLevel of the incoming message |