/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2017,  The University of Memphis,
 *                           Regents of the University of California
 *
 * This file is part of NLSR (Named-data Link State Routing).
 * See AUTHORS.md for complete list of NLSR authors and contributors.
 *
 * NLSR is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 *
 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
 *
 **/
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/patternlayout.h>
#include <log4cxx/level.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/rollingfileappender.h>

#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>

#include "logger.hpp"

void
INIT_LOG4CXX(const std::string& log4cxxConfPath)
{
  if (boost::filesystem::path(log4cxxConfPath).extension().string() == ".xml") {
    log4cxx::xml::DOMConfigurator::configure(log4cxxConfPath);
  }
  else {
    log4cxx::PropertyConfigurator::configure(log4cxxConfPath);
  }
}

void
INIT_LOGGERS(const std::string& logDir, const std::string& logLevel)
{
  static bool configured = false;

  if (configured) {
    return;
  }

  log4cxx::PatternLayoutPtr
           layout(new log4cxx::PatternLayout("%date{%s}.%date{SSS} %p: [%c] %m%n"));

  log4cxx::RollingFileAppender* rollingFileAppender =
           new log4cxx::RollingFileAppender(layout, logDir+"/nlsr.log", true);

  rollingFileAppender->setMaxFileSize("10MB");
  rollingFileAppender->setMaxBackupIndex(10);

  log4cxx::helpers::Pool p;
  rollingFileAppender->activateOptions(p);

  log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(rollingFileAppender));

  if (boost::iequals(logLevel, "none")) {
    log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getOff());
  }
  else {
    log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::toLevel(logLevel));
  }

  configured = true;
}

bool
isValidLogLevel(const std::string& logLevel)
{
  return boost::iequals(logLevel, "all")   || boost::iequals(logLevel, "trace") ||
         boost::iequals(logLevel, "debug") || boost::iequals(logLevel, "info")  ||
         boost::iequals(logLevel, "warn")  || boost::iequals(logLevel, "error") ||
         boost::iequals(logLevel, "none");
}
