<commit_before>/*!
 * \cond FILEINFO
 ******************************************************************************
 * \file logger.cpp
 ******************************************************************************
 *
 * Copyright (C) ATS Advanced Telematic Systems GmbH GmbH, 2016
 *
 * \author <NAME>
 *
 ******************************************************************************
 *
 * \brief  Refer to the modules header file logger.hpp.
 *
 *
 ******************************************************************************
 *
 * \endcond
 */

#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <iostream>
#include <string>

#include "logger.hpp"

/*****************************************************************************/
namespace logging = boost::log;
namespace keywords = boost::log::keywords;
namespace logtrv = boost::log::trivial;

/*****************************************************************************/

static loggerLevels_t
    logger_globalLvl; /**< store the currently used severity level */

/*****************************************************************************/

// refer to boost::log::trivial::severity_level enumeration
#define LOG_INIT_LEVEL \
  LVL_warning /**< default logging level used for initialization */

/*****************************************************************************/
void logger_init(void) {
  // choose stderr as logging console
  logging::add_console_log(std::cerr,
                           keywords::format = "[%TimeStamp%]: %Message%");

  // apply default attributes
  logging::add_common_attributes();

  // set the initial severity level
  logger_setSeverity(LOG_INIT_LEVEL);
}

/*****************************************************************************/
void logger_setSeverity(loggerLevels_t lvl) {
  // set global logging level by applying an corresponding filter

  if (lvl <= LVL_error) {
    logging::core::get()->set_filter(logtrv::severity >=
                                     static_cast<logtrv::severity_level>(lvl));

    // store the currently used log level
    logger_globalLvl = lvl;

    // write an log message
    LOGGER_LOG(LVL_debug,
               "loglevel set to "
                   << static_cast<logtrv::severity_level>(logger_globalLvl));
  } else {
    LOGGER_LOG(LVL_debug, "Invalid log level received: " << lvl);
  }
}

/*****************************************************************************/<commit_msg>logging to stout<commit_after>/*!
 * \cond FILEINFO
 ******************************************************************************
 * \file logger.cpp
 ******************************************************************************
 *
 * Copyright (C) ATS Advanced Telematic Systems GmbH GmbH, 2016
 *
 * \author <NAME>
 *
 ******************************************************************************
 *
 * \brief  Refer to the modules header file logger.hpp.
 *
 *
 ******************************************************************************
 *
 * \endcond
 */

#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <iostream>
#include <string>

#include "logger.hpp"

/*****************************************************************************/
namespace logging = boost::log;
namespace keywords = boost::log::keywords;
namespace logtrv = boost::log::trivial;

/*****************************************************************************/

static loggerLevels_t
    logger_globalLvl; /**< store the currently used severity level */

/*****************************************************************************/

// refer to boost::log::trivial::severity_level enumeration
#define LOG_INIT_LEVEL \
  LVL_warning /**< default logging level used for initialization */

/*****************************************************************************/
void logger_init(void) {
  // choose stderr as logging console
  logging::add_console_log(std::cout,
                           keywords::format = "[%TimeStamp%]: %Message%");

  // apply default attributes
  logging::add_common_attributes();

  // set the initial severity level
  logger_setSeverity(LOG_INIT_LEVEL);
}

/*****************************************************************************/
void logger_setSeverity(loggerLevels_t lvl) {
  // set global logging level by applying an corresponding filter

  if (lvl <= LVL_error) {
    logging::core::get()->set_filter(logtrv::severity >=
                                     static_cast<logtrv::severity_level>(lvl));

    // store the currently used log level
    logger_globalLvl = lvl;

    // write an log message
    LOGGER_LOG(LVL_debug,
               "loglevel set to "
                   << static_cast<logtrv::severity_level>(logger_globalLvl));
  } else {
    LOGGER_LOG(LVL_debug, "Invalid log level received: " << lvl);
  }
}

/*****************************************************************************/
{'fraction_non_alphanumeric': 0.38282579912994136, 'fraction_numerical': 0.0015131454511064877, 'mean_word_length': 5.0159271899886235, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5747419', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1223, 'n_words': 274}