![]() |
SOPT
Sparse OPTimisation
|
Logging system for controlled & formatted writing to stdout. More...
#include <logging.h>
Public Types | |
enum | Level { trace = 0 , debug = 10 , info = 20 , warn = 30 , warning = 30 , error = 40 , critical = 50 , always = 50 } |
Log priority levels. More... | |
using | LogMap = std::map< std::string, Log > |
Typedef for a collection of named logs. More... | |
using | LevelMap = std::map< std::string, int > |
Typedef for a collection of named log levels. More... | |
using | ColorCodes = std::map< int, std::string > |
Typedef for a collection of shell color codes, accessed by log level. More... | |
Public Member Functions | |
int | getLevel () const |
Get the priority level of this logger. More... | |
Log & | setLevel (int level) |
Set the priority level of this logger. More... | |
std::string | getName () const |
Get the name of this logger. More... | |
Log & | setName (const std::string &name) |
Set the name of this logger. More... | |
bool | isActive (int level) const |
Will this log level produce output on this logger at the moment? More... | |
Static Public Member Functions | |
static void | setLevel (const std::string &name, int level) |
Set the log levels. More... | |
static void | setLevels (const LevelMap &logLevels) |
static Log & | getLog (const std::string &name) |
static Level | getLevelFromName (const std::string &level) |
Get a log level enum from a string. More... | |
static std::string | getLevelName (int level) |
Get the std::string representation of a log level. More... | |
Static Public Attributes | |
static const int | end_color {-10} |
Special "level-like" code to end coloring. More... | |
Friends | |
std::ostream & | operator<< (Log &log, int level) |
The streaming operator can use Log's internals. More... | |
Logging system for controlled & formatted writing to stdout.
using sopt::logging::Log::ColorCodes = std::map<int, std::string> |
using sopt::logging::Log::LevelMap = std::map<std::string, int> |
using sopt::logging::Log::LogMap = std::map<std::string, Log> |
|
inline |
|
static |
Get a log level enum from a string.
Definition at line 138 of file logging.cc.
References SOPT_THROW.
Referenced by sopt::logging::set_level().
|
static |
Get the std::string representation of a log level.
Definition at line 95 of file logging.cc.
|
static |
Get a logger with the given name. The level will be taken from the "requestedLevels" static map or will be INFO by default.
Definition at line 57 of file logging.cc.
References getLevel().
Referenced by sopt::logging::getLog().
|
inline |
|
inline |
|
static |
Set the log levels.
Referenced by sopt::logging::set_level().
|
inline |
|
static |
Definition at line 49 of file logging.cc.
References sopt::logging::_updateLevels().
|
inline |
|
friend |
|
static |