SOMHunter Core
static-logger.hpp File Reference
#include <cmath>
#include <exception>
#include <fstream>
#include <iostream>
#include <mutex>
#include <sstream>
#include <string>
#include <string_view>
#include "common.h"
Include dependency graph for static-logger.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TermColor::Modifier
 

Namespaces

 TermColor
 
 sh
 

Macros

#define FILE_NAME_TAIL_LEN   50
 
#define SHLOG(x)
 Undecorated log to the current log stream. More...
 
#define SHLOG_E(x)
 
#define SHLOG_E_THROW(x)
 
#define _write_log_err(level, x)
 
#define SHLOG_W(x)   _dont_write_log_err
 
#define SHLOG_I(x)   _dont_write_log_err
 
#define SHLOG_S(x)   _dont_write_log_err
 
#define SHLOG_D(x)   _dont_write_log_err
 
#define SHLOG_REQ(id, x)   _dont_write_log_err
 
#define SHLOG_UNREQ(id, x)   _dont_write_log_err
 
#define do_assert(assertion, msg)
 Assert execuded at all times. More...
 
#define do_assert_equals(a, b, msg)   do_assert(a == b, msg);
 Assert on equals execuded at all times. More...
 
#define do_assert_debug(assertion, msg)
 Assert execuded only if RUN_ASSERTS is true. More...
 

Enumerations

enum  TermColor::Code {
  TermColor::FG_RED = 31 , TermColor::FG_GREEN = 32 , TermColor::FG_YELLOW = 33 , TermColor::FG_BLUE = 34 ,
  TermColor::FG_CYAN = 36 , TermColor::FG_WHITE = 37 , TermColor::FG_GREY = 90 , TermColor::FG_DEFAULT = 39 ,
  TermColor::BG_RED = 41 , TermColor::BG_GREEN = 42 , TermColor::BG_YELLOW = 43 , TermColor::BG_BLUE = 44 ,
  TermColor::BG_CYAN = 46 , TermColor::BG_WHITE = 47 , TermColor::BG_GREY = 100 , TermColor::BG_DEFAULT = 49
}
 

Variables

constexpr bool RUN_ASSERTS = true
 If true the assertions will be executed. More...
 
std::mutex logger_mtx
 Mutex for optional STDOUT/STDERR synchronization. More...
 

Macro Definition Documentation

◆ _write_log_err

#define _write_log_err (   level,
 
)

◆ do_assert

#define do_assert (   assertion,
  msg 
)
Value:
do { \
if (!(assertion)) { \
std::cerr << "ASSERTION FAILED: " << msg << "\n\t" \
<< "." \
<< "() in " << view_tail(__FILE__, FILE_NAME_TAIL_LEN) << " :" << __LINE__ << "" << std::endl; \
throw std::runtime_error("ASSERTION FAILED!"); \
} \
} while (0)
#define FILE_NAME_TAIL_LEN
Definition: static-logger.hpp:46

Assert execuded at all times.

◆ do_assert_debug

#define do_assert_debug (   assertion,
  msg 
)
Value:
do { \
if constexpr (RUN_ASSERTS) { \
do_assert(assertion, msg); \
} \
} while (0)
constexpr bool RUN_ASSERTS
If true the assertions will be executed.
Definition: static-logger.hpp:49

Assert execuded only if RUN_ASSERTS is true.

◆ do_assert_equals

#define do_assert_equals (   a,
  b,
  msg 
)    do_assert(a == b, msg);

Assert on equals execuded at all times.

◆ FILE_NAME_TAIL_LEN

#define FILE_NAME_TAIL_LEN   50

◆ SHLOG

#define SHLOG (   x)
Value:
do { \
[[maybe_unused]] auto static_logger_lck{ lock_out() }; \
std::cout << x << std::endl; \
} while (0)

Undecorated log to the current log stream.

◆ SHLOG_D

#define SHLOG_D (   x)    _dont_write_log_err

◆ SHLOG_E

#define SHLOG_E (   x)

◆ SHLOG_E_THROW

#define SHLOG_E_THROW (   x)

◆ SHLOG_I

#define SHLOG_I (   x)    _dont_write_log_err

◆ SHLOG_REQ

#define SHLOG_REQ (   id,
 
)    _dont_write_log_err

◆ SHLOG_S

#define SHLOG_S (   x)    _dont_write_log_err

◆ SHLOG_UNREQ

#define SHLOG_UNREQ (   id,
 
)    _dont_write_log_err

◆ SHLOG_W

#define SHLOG_W (   x)    _dont_write_log_err

Variable Documentation

◆ logger_mtx

std::mutex logger_mtx
inline

Mutex for optional STDOUT/STDERR synchronization.

◆ RUN_ASSERTS

constexpr bool RUN_ASSERTS = true
constexpr

If true the assertions will be executed.