//
// Created by rhetenor on 13.09.18.
//

#include "LoggerFactory.h"

#ifndef EASYLOGGING_IS_INITIALIZED
#define EASYLOGGING_IS_INITIALIZED
INITIALIZE_EASYLOGGINGPP
#endif

namespace flippR_driver
{
namespace utility
{
namespace LoggerFactory
{

void CreateInputTestLogger(el::Level level)
{
  el::Loggers::getLogger(INPUT_LOGGER);
  el::Configurations conf;

  conf.setToDefault();

  conf.set(level, el::ConfigurationType::ToFile, "false");
  conf.set(level, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");

  el::Loggers::reconfigureAllLoggers(conf);
}

el::Configurations createConfig(el::Level level)
{
  el::Configurations conf;
  conf.setToDefault();

  conf.setGlobally(el::ConfigurationType::ToStandardOutput, "false");

  conf.set(level, el::ConfigurationType::ToStandardOutput, "true");
  conf.set(level, el::ConfigurationType::ToFile, "true");
  conf.set(level, el::ConfigurationType::Filename, LOGGER_FILE);
  conf.set(level, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");

  return conf;
}

void CreateInputLogger(el::Level level)
{
  el::Loggers::getLogger(INPUT_LOGGER);

  el::Configurations conf = createConfig(level);

  el::Loggers::reconfigureLogger(INPUT_LOGGER, conf);
}

void CreateOutputLogger(el::Level level)
{
  el::Loggers::getLogger(OUTPUT_LOGGER);

  el::Configurations conf = createConfig(level);

  el::Loggers::reconfigureLogger(OUTPUT_LOGGER, conf);
}

};

}
}