SNode.C
Loading...
Searching...
No Matches
logger::Logger Class Reference

#include <Logger.h>

Collaboration diagram for logger::Logger:

Public Member Functions

 Logger ()=delete
 ~Logger ()=delete

Static Public Member Functions

static void init ()
static void setLogLevel (int level)
static void setVerboseLevel (int level)
static void logToFile (const std::string &logFile)
static void setQuiet (bool quiet=true)
static void setCustomFormatSpec (const char *format, const el::FormatSpecifierValueResolver &resolver)
static void setDisableColor (bool disableColorLog=true)
static bool getDisableColor ()

Static Protected Attributes

static bool disableColorLog = false

Friends

std::ostream & Color::operator<< (std::ostream &os, const Color::Code &code)
std::string Color::operator+ (const std::string &string, const Color::Code &code)
std::string Color::operator+ (const Color::Code &code, const std::string &string)

Detailed Description

Definition at line 101 of file Logger.h.

Constructor & Destructor Documentation

◆ Logger()

logger::Logger::Logger ( )
delete

◆ ~Logger()

logger::Logger::~Logger ( )
delete

Member Function Documentation

◆ getDisableColor()

bool logger::Logger::getDisableColor ( )
static

Definition at line 94 of file Logger.cpp.

94 {
95 return disableColorLog;
96 }
static bool disableColorLog
Definition Logger.h:124

References disableColorLog.

Referenced by utils::ConfigRoot::addRootOptions().

Here is the caller graph for this function:

◆ init()

void logger::Logger::init ( )
static

Definition at line 54 of file Logger.cpp.

54 {
55 el::Configurations conf = *el::Loggers::defaultConfigurations();
56
57 conf.setGlobally(el::ConfigurationType::Enabled, "true");
58 conf.setGlobally(el::ConfigurationType::Format, "%datetime{%Y-%M-%d %H:%m:%s} %tick %level %msg");
59 conf.setGlobally(el::ConfigurationType::ToFile, "false");
60 conf.setGlobally(el::ConfigurationType::ToStandardOutput, "true");
61 conf.setGlobally(el::ConfigurationType::SubsecondPrecision, "2");
62 conf.setGlobally(el::ConfigurationType::PerformanceTracking, "false");
63 conf.setGlobally(el::ConfigurationType::MaxLogFileSize, "2097152");
64 conf.setGlobally(el::ConfigurationType::LogFlushThreshold, "0");
65 conf.set(el::Level::Verbose, el::ConfigurationType::Format, "%datetime{%Y-%M-%d %H:%m:%s} %tick %msg");
66
67 el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
68 el::Loggers::addFlag(el::LoggingFlag::DisablePerformanceTrackingCheckpointComparison);
69 el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput);
70 el::Loggers::removeFlag(el::LoggingFlag::AllowVerboseIfModuleNotSpecified);
71
72 el::Loggers::setDefaultConfigurations(conf, true);
73
74 setDisableColor(::isatty(::fileno(stdout)) == 0);
75
77 setLogLevel(0);
78 }
static void setDisableColor(bool disableColorLog=true)
Definition Logger.cpp:84
static void setVerboseLevel(int level)
Definition Logger.cpp:137
static void setLogLevel(int level)
Definition Logger.cpp:100

References setDisableColor(), setLogLevel(), and setVerboseLevel().

Referenced by utils::ConfigRoot::ConfigRoot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logToFile()

void logger::Logger::logToFile ( const std::string & logFile)
static

Definition at line 143 of file Logger.cpp.

143 {
144 el::Configurations conf = *el::Loggers::defaultConfigurations();
145
146 conf.setGlobally(el::ConfigurationType::Filename, logFile);
147 conf.setGlobally(el::ConfigurationType::ToFile, "true");
148
149 el::Loggers::setDefaultConfigurations(conf, true);
150 }

Referenced by utils::ConfigRoot::bootstrap().

Here is the caller graph for this function:

◆ setCustomFormatSpec()

void logger::Logger::setCustomFormatSpec ( const char * format,
const el::FormatSpecifierValueResolver & resolver )
static

Definition at line 80 of file Logger.cpp.

80 {
81 el::Helpers::installCustomFormatSpecifier(el::CustomFormatSpecifier(format, resolver));
82 }

Referenced by core::EventLoop::init().

Here is the caller graph for this function:

◆ setDisableColor()

void logger::Logger::setDisableColor ( bool disableColorLog = true)
static

Definition at line 84 of file Logger.cpp.

84 {
85 if (disableColorLog) {
86 el::Loggers::removeFlag(el::LoggingFlag::ColoredTerminalOutput);
87 } else {
88 el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput);
89 }
90
92 }

References disableColorLog.

Referenced by utils::ConfigRoot::addRootOptions(), and init().

Here is the caller graph for this function:

◆ setLogLevel()

void logger::Logger::setLogLevel ( int level)
static

Definition at line 100 of file Logger.cpp.

100 {
101 el::Configurations conf = *el::Loggers::defaultConfigurations();
102
103 conf.set(el::Level::Trace, el::ConfigurationType::Enabled, "false"); // trace method/function calling
104 conf.set(el::Level::Debug, el::ConfigurationType::Enabled, "false"); // typical assert messages - but we can go on
105 conf.set(el::Level::Info, el::ConfigurationType::Enabled, "false"); // additional infos - what 's going on
106 conf.set(el::Level::Warning, el::ConfigurationType::Enabled, "false"); // not that serious but mentioning
107 conf.set(el::Level::Error, el::ConfigurationType::Enabled, "false"); // serious errors - but we can go on
108 conf.set(el::Level::Fatal, el::ConfigurationType::Enabled, "false"); // asserts - stop - we can not go on
109
110 switch (level) {
111 case 6:
112 conf.set(el::Level::Trace, el::ConfigurationType::Enabled, "true");
113 [[fallthrough]];
114 case 5:
115 conf.set(el::Level::Debug, el::ConfigurationType::Enabled, "true");
116 [[fallthrough]];
117 case 4:
118 conf.set(el::Level::Info, el::ConfigurationType::Enabled, "true");
119 [[fallthrough]];
120 case 3:
121 conf.set(el::Level::Warning, el::ConfigurationType::Enabled, "true");
122 [[fallthrough]];
123 case 2:
124 conf.set(el::Level::Error, el::ConfigurationType::Enabled, "true");
125 [[fallthrough]];
126 case 1:
127 conf.set(el::Level::Fatal, el::ConfigurationType::Enabled, "true");
128 [[fallthrough]];
129 case 0:
130 [[fallthrough]];
131 default:;
132 }
133
134 el::Loggers::setDefaultConfigurations(conf, true);
135 }

Referenced by init(), and utils::ConfigRoot::parse1().

Here is the caller graph for this function:

◆ setQuiet()

void logger::Logger::setQuiet ( bool quiet = true)
static

Definition at line 152 of file Logger.cpp.

152 {
153 el::Configurations conf = *el::Loggers::defaultConfigurations();
154
155 conf.setGlobally(el::ConfigurationType::ToStandardOutput, quiet ? "false" : "true");
156
157 el::Loggers::setDefaultConfigurations(conf, true);
158 }

Referenced by utils::ConfigRoot::bootstrap(), utils::ConfigRoot::parse1(), and utils::ConfigRoot::parse2().

Here is the caller graph for this function:

◆ setVerboseLevel()

void logger::Logger::setVerboseLevel ( int level)
static

Definition at line 137 of file Logger.cpp.

137 {
138 if (level >= 0) {
139 el::Loggers::setVerboseLevel(static_cast<el::base::type::VerboseLevel>(level));
140 }
141 }

Referenced by init(), and utils::ConfigRoot::parse1().

Here is the caller graph for this function:

◆ Color::operator+ [1/2]

std::string Color::operator+ ( const Color::Code & code,
const std::string & string )
friend

◆ Color::operator+ [2/2]

std::string Color::operator+ ( const std::string & string,
const Color::Code & code )
friend

◆ Color::operator<<

std::ostream & Color::operator<< ( std::ostream & os,
const Color::Code & code )
friend

Member Data Documentation

◆ disableColorLog

bool logger::Logger::disableColorLog = false
staticprotected

The documentation for this class was generated from the following files: