AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::log Namespace Reference

AnCH logging library namespace. More...

Namespaces

namespace  fmt
 Logger message formatters.
namespace  lvl
 Logging levels as types for the stream API.

Classes

class  ConsoleWriter
 Log file writer. More...
class  FileWriter
 Log file writer. More...
struct  LevelTag
class  Logger
class  LoggerConfiguration
class  LoggerFactory
 Logger factory. More...
class  LogLine
class  LowPriorityWriter
class  MapDiagnosticContext
 Map Diagnostic Context. More...
class  NoopStream
class  ThreadSafeWriter
class  Writer
 Logger writter definition. More...
class  WriterRegistry
 Logger writers' registry. More...

Typedefs

using CreateWriter = std::function<anch::log::Writer*(bool, bool, const anch::conf::Section&)>

Enumerations

enum class  Level {
  TRACE = 0 , DEBUG = 10 , INFO = 20 , WARN = 30 ,
  ERROR = 40 , FATAL = 50
}

Functions

template<anch::log::Level L>
auto operator<< (const anch::log::Logger &logger, anch::log::LevelTag< L > level) noexcept

Variables

const std::string DEFAULT
const std::string MODULE
const std::string THREAD_SAFE
const std::string LOW_PRIORITY
const std::string WRITER
const std::string WRITERS
const std::string LOGGER
const std::string LEVEL
const std::string NS_LOG
const std::string WRITER_FILE
const std::string WRITER_TERM
const std::map< const Level, const std::string > LEVEL_LABEL
const std::map< const std::string, const Level > LABEL_LEVEL
constexpr anch::log::Level MIN_LEVEL = anch::log::Level::ANCH_LOG_MIN_LEVEL
const std::string MDC_THREAD_ID
std::map< std::string, std::string > MDC_CONST
MapDiagnosticContext MDC

Detailed Description

AnCH logging library namespace.

It contains the logging library: LoggerFactory retrieves configured Logger instances, which write messages through writers. Messages can be logged with variadic methods (LOG.info("value=", value) ) or with stream injection (log/stream.hpp ).

Typedef Documentation

◆ CreateWriter

using anch::log::CreateWriter = std::function<anch::log::Writer*(bool, bool, const anch::conf::Section&)>

Create writer definition

Parameters
threadSafedefault thread safe flag
lowPrioritydefault low priority flag
sectionthe writer section
Returns
the new writer

Enumeration Type Documentation

◆ Level

enum class anch::log::Level
strong

Logging levels declaration

Author
Vincent Lachenal
Enumerator
TRACE 

Trace logging level

DEBUG 

Debug logging level

INFO 

Information logging level

WARN 

Warning logging level

ERROR 

Error logging level

FATAL 

Fatal logging level

Function Documentation

◆ operator<<()

template<anch::log::Level L>
auto anch::log::operator<< ( const anch::log::Logger & logger,
anch::log::LevelTag< L > level )
nodiscardnoexcept

Start a log line.
Return type depends on level: NoopStream when level is lower than MIN_LEVEL , LogLine otherwise.

Parameters
loggerThe logger
levelThe level (anch::log::lvl::debug , ...)
Returns
the log line
Since
0.2

Variable Documentation

◆ DEFAULT

const std::string anch::log::DEFAULT
extern

'' constant

◆ LABEL_LEVEL

const std::map<const std::string, const Level> anch::log::LABEL_LEVEL
extern

Labels->levels for logging definition

◆ LEVEL

const std::string anch::log::LEVEL
extern

'level' constant

◆ LEVEL_LABEL

const std::map<const Level, const std::string> anch::log::LEVEL_LABEL
extern

Level->labels for logging defintion

◆ LOGGER

const std::string anch::log::LOGGER
extern

'logger' constant

◆ LOW_PRIORITY

const std::string anch::log::LOW_PRIORITY
extern

'low-priority' constant

◆ MDC

MapDiagnosticContext anch::log::MDC
externthread_local

MapDiagnosticContext current thread instance

◆ MDC_CONST

std::map<std::string,std::string> anch::log::MDC_CONST
extern

MDC constant values

◆ MDC_THREAD_ID

const std::string anch::log::MDC_THREAD_ID
extern

Thread ID key in diagnostic context

◆ MIN_LEVEL

anch::log::Level anch::log::MIN_LEVEL = anch::log::Level::ANCH_LOG_MIN_LEVEL
inlineconstexpr

Compile-time logging threshold (set with ANCH_LOG_MIN_LEVEL ).
Messages in lower levels are removed at compilation.

Since
0.2

◆ MODULE

const std::string anch::log::MODULE
extern

'module' constant

◆ NS_LOG

const std::string anch::log::NS_LOG
extern

'anch::log' constant

◆ THREAD_SAFE

const std::string anch::log::THREAD_SAFE
extern

'thread-safe' constant

◆ WRITER

const std::string anch::log::WRITER
extern

'writer' constant

◆ WRITER_FILE

const std::string anch::log::WRITER_FILE
extern

'file' constant

◆ WRITER_TERM

const std::string anch::log::WRITER_TERM
extern

'console' constant

◆ WRITERS

const std::string anch::log::WRITERS
extern

'writers' constant