<commit_before>/* *************************************************
 * Filename:g2log.h  Framework for Logging and Design By Contract
 * Created: 2011 by <NAME>
 *
 * PUBLIC DOMAIN and Not copywrited since it was built on public-domain software and influenced
 * from the following sources
 * 1. kjellkod.cc ;)
 * 2. Dr.Dobbs, <NAME>:  http://drdobbs.com/article/printableArticle.jhtml?articleId=201804215&dept_url=/cpp/
 * 3. Dr.Dobbs, <NAME>: http://drdobbs.com/article/printableArticle.jhtml?articleId=225700666&dept_url=/cpp/
 * 4. Google 'glog': http://google-glog.googlecode.com/svn/trunk/doc/glog.html
 * 5. Various Q&A at StackOverflow
 * ********************************************* */


#ifndef G2LOG_H
#define G2LOG_H

#include <string>
#include <sstream>
#include <iostream>
#include <cstdarg>
#include <chrono>

class LogWorker;

#if !(defined(__PRETTY_FUNCTION__))
#define __PRETTY_FUNCTION__   __FUNCTION__
#endif


// Levels for logging, made so that it would be easy to change, remove, add levels -- KjellKod
const int DEBUG = 0, INFO = 1, WARNING = 2, FATAL = 3;
static const std::string k_os_signal_fatal_text = "OS_SIGNAL_FATAL";
static const std::string k_fatal_log_expression = ""; // using LogContractMessage but no boolean expression

// GCC Predefined macros: http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html
//     and http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html
//
// The ## macro is helpful as it gives compile time error in case there's a typo
// Example: MYLEVEL doesn't exist so LOG(MYLEVEL) << "bla bla bla"; would
//         generate a compile error when it is rolled out by the
//         macro as G2_LOG_MYLEVEL, since "#define G2_LOG_MYLEVEL" doesn't exist


// BELOW -- LOG stream syntax
#define G2_LOG_DEBUG  g2::internal::LogMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__,"DEBUG")
#define G2_LOG_INFO  g2::internal::LogMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__,"INFO")
#define G2_LOG_WARNING  g2::internal::LogMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__,"WARNING")
#define G2_LOG_FATAL  g2::internal::LogContractMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__,k_fatal_log_expression)

// LOG(level) is the API for the stream log
#define LOG(level) G2_LOG_##level.messageStream()

// conditional stream log
#define LOG_IF(level, boolean_expression)  \
  if(true == boolean_expression)          \
     G2_LOG_##level.messageStream()
<commit_msg>removed uncecessary variable<commit_after>/* *************************************************
 * Filename:g2log.h  Framework for Logging and Design By Contract
 * Created: 2011 by <NAME>
 *
 * PUBLIC DOMAIN and Not copywrited since it was built on public-domain software and influenced
 * from the following sources
 * 1. kjellkod.cc ;)
 * 2. Dr.Dobbs, <NAME>:  http://drdobbs.com/article/printableArticle.jhtml?articleId=201804215&dept_url=/cpp/
 * 3. Dr.Dobbs, <NAME>: http://drdobbs.com/article/printableArticle.jhtml?articleId=225700666&dept_url=/cpp/
 * 4. Google 'glog': http://google-glog.googlecode.com/svn/trunk/doc/glog.html
 * 5. Various Q&A at StackOverflow
 * ********************************************* */


#ifndef G2LOG_H
#define G2LOG_H

#include <string>
#include <sstream>
#include <iostream>
#include <cstdarg>
#include <chrono>

class LogWorker;

#if !(defined(__PRETTY_FUNCTION__))
#define __PRETTY_FUNCTION__   __FUNCTION__
#endif


// Levels for logging, made so that it would be easy to change, remove, add levels -- KjellKod
const int DEBUG = 0, INFO = 1, WARNING = 2, FATAL = 3;
static const std::string k_fatal_log_expression = ""; // using LogContractMessage but no boolean expression

// GCC Predefined macros: http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html
//     and http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html
//
// The ## macro is helpful as it gives compile time error in case there's a typo
// Example: MYLEVEL doesn't exist so LOG(MYLEVEL) << "bla bla bla"; would
//         generate a compile error when it is rolled out by the
//         macro as G2_LOG_MYLEVEL, since "#define G2_LOG_MYLEVEL" doesn't exist


// BELOW -- LOG stream syntax
#define G2_LOG_DEBUG  g2::internal::LogMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__,"DEBUG")
#define G2_LOG_INFO  g2::internal::LogMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__,"INFO")
#define G2_LOG_WARNING  g2::internal::LogMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__,"WARNING")
#define G2_LOG_FATAL  g2::internal::LogContractMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__,k_fatal_log_expression)

// LOG(level) is the API for the stream log
#define LOG(level) G2_LOG_##level.messageStream()

// conditional stream log
#define LOG_IF(level, boolean_expression)  \
  if(true == boolean_expression)          \
     G2_LOG_##level.messageStream()

{'fraction_non_alphanumeric': 0.15129924559932942, 'fraction_numerical': 0.019279128248113998, 'mean_word_length': 5.034134007585335, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7273962', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1546, 'n_words': 395}