11 INITIALIZE_EASYLOGGINGPP
16 el::Configurations DefaultConfig;
18 DefaultConfig.setToDefault();
19 DefaultConfig.setGlobally(el::ConfigurationType::Format,
20 "%datetime [%level] %msg");
21 if (filename.empty()) {
22 DefaultConfig.setGlobally(el::ConfigurationType::ToFile,
"0");
23 LOG(INFO) <<
"Logging to file disabled!";
25 DefaultConfig.setGlobally(el::ConfigurationType::Filename, filename);
26 DefaultConfig.setGlobally(el::ConfigurationType::ToFile,
"1");
27 LOG(INFO) <<
"Log file: " << filename;
30 el::Loggers::reconfigureLogger(
"default", DefaultConfig);
34 LOG(INFO) <<
"Log level: " << level;
38 std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
40 LOG(INFO) <<
"Current date and time: " << std::ctime(&time);
47 logger->configurations()->set(el::Level::Trace,
48 el::ConfigurationType::Enabled, levels.at(0));
49 logger->configurations()->set(el::Level::Debug,
50 el::ConfigurationType::Enabled, levels.at(1));
51 logger->configurations()->set(el::Level::Info, el::ConfigurationType::Enabled,
53 logger->configurations()->set(el::Level::Warning,
54 el::ConfigurationType::Enabled, levels.at(3));
55 logger->configurations()->set(el::Level::Error,
56 el::ConfigurationType::Enabled, levels.at(4));
61 std::transform(level.begin(), level.end(), level.begin(), ::toupper);
66 ELPP->registeredLoggers()->get(el::base::consts::kDefaultLoggerId);
77 else if (level ==
"DEBUG")
79 else if (level ==
"INFO")
81 else if (level ==
"WARNING")
83 else if (level ==
"ERROR")
85 else if (level ==
"FATAL")
91 <<
"Logging::setLogLevel() | Unknown log level " + level +
92 ". Available levels are: \"TRACE\", \"DEBUG\", \"INFO\", " 93 "\"WARNING\", \"ERROR\", \"FATAL\". Setting log level " 96 logger->reconfigure();
void enableDisableLvl(el::Logger *logger, std::array< std::string, 5 > levels)
Enable or disable levels TRACE, DEBUG, INFO, WARNING, ERROR, FATAL.
void setLogLevel(std::string level)
Logging(std::string level="INFO", std::string filename="")