configured logger

This commit is contained in:
Neeflix
2018-07-16 22:44:09 +02:00
parent 7cb8ff24c9
commit c37b1183ab
9 changed files with 35 additions and 18 deletions

View File

@@ -45,7 +45,7 @@ void Detector::detect()
}
catch(std::out_of_range& e)
{
CLOG(WARNING, INPUT_LOGGER) << "Did not found event for address: " << address << " check config-file";
CLOG_N_TIMES(1, WARNING, INPUT_LOGGER) << "Did not found event for address: " << address << " check config-file";
}
}
}

View File

@@ -72,7 +72,7 @@ std::map<char, Event> InputDriverFactory::create_input_events(json matrix_config
void InputDriverFactory::ConfigureLogger()
{
LoggerFactory::CreateInputLogger();
LoggerFactory::CreateInputTestLogger();
}

View File

@@ -13,17 +13,31 @@
class LoggerFactory
{
public:
static void CreateInputTestLogger()
{
el::Loggers::getLogger(INPUT_LOGGER);
el::Configurations conf;
conf.setToDefault();
conf.set(el::Level::Global, el::ConfigurationType::ToFile, "false");
conf.set(el::Level::Global, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");
el::Loggers::reconfigureAllLoggers(conf);
}
static void CreateInputLogger()
{
el::Loggers::getLogger(INPUT_LOGGER);
el::Loggers::getLogger(INPUT_LOGGER);
//TODO may configure?
el::Configurations conf;
conf.setToDefault();
conf.set(el::Level::Global, el::ConfigurationType::Filename, DRIVER_LOG_FILE);
conf.set(el::Level::Global, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");
el::Configurations conf;
conf.setToDefault();
el::Loggers::reconfigureLogger(INPUT_LOGGER, conf);
conf.set(el::Level::Global, el::ConfigurationType::ToFile, "true");
conf.set(el::Level::Global, el::ConfigurationType::Filename, INPUT_LOGGER_FILE);
conf.set(el::Level::Global, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");
el::Loggers::reconfigureLogger(INPUT_LOGGER, conf);
}
};

View File

@@ -8,7 +8,9 @@
#include "easylogging++.h"
#define INPUT_LOGGER "driver_logger"
#define DRIVER_LOG_FILE "/var/log/flippr_driver.conf"
#define INPUT_LOGGER_FILE "input_driver.log"
#define DRIVER_CONF_FILE "/var/log/flippr_driver.conf"
#define HIGH_VERBOSITY 10