CPPxDIC
C++ Digital Image Correlation library for fingertip 3D reconstruction
Loading...
Searching...
No Matches
cppxdic::log::Logger Class Reference

Process-wide singleton logger. More...

#include <logging.h>

Public Member Functions

void setConsoleLevel (Level l)
 
void setFileLevel (Level l)
 
Level consoleLevel () const
 
Level fileLevel () const
 
bool setFile (const std::string &path)
 Open (or replace) the file sink.
 
void setConsoleEnabled (bool on)
 Enable or disable console output entirely.
 
void setVerboseFormat (bool on)
 Include timestamp + source location in console output too (the file sink always includes them).
 
void configureFromEnv ()
 Apply CPPXDIC_LOG_LEVEL / CPPXDIC_LOG_FILE / CPPXDIC_LOG_CONSOLE.
 
bool enabled (Level l)
 True if a message at l would reach any sink.
 
void write (Level l, const char *file, int line, const std::string &msg)
 Emit a fully-formed message (trailing newlines trimmed) at l.
 

Static Public Member Functions

static Logger & instance ()
 

Detailed Description

Process-wide singleton logger.

All members are thread-safe.

Definition at line 52 of file logging.h.

Member Function Documentation

◆ configureFromEnv()

void cppxdic::log::Logger::configureFromEnv ( )

Apply CPPXDIC_LOG_LEVEL / CPPXDIC_LOG_FILE / CPPXDIC_LOG_CONSOLE.

Runs once automatically on first use; calling again re-applies them.

Definition at line 141 of file logging.cpp.

◆ consoleLevel()

Level cppxdic::log::Logger::consoleLevel ( ) const

Definition at line 164 of file logging.cpp.

◆ enabled()

bool cppxdic::log::Logger::enabled ( Level  l)

True if a message at l would reach any sink.

Use to guard expensive message construction in hot loops.

Definition at line 192 of file logging.cpp.

◆ fileLevel()

Level cppxdic::log::Logger::fileLevel ( ) const

Definition at line 169 of file logging.cpp.

◆ instance()

Logger & cppxdic::log::Logger::instance ( )
static

Definition at line 125 of file logging.cpp.

◆ setConsoleEnabled()

void cppxdic::log::Logger::setConsoleEnabled ( bool  on)

Enable or disable console output entirely.

Definition at line 182 of file logging.cpp.

◆ setConsoleLevel()

void cppxdic::log::Logger::setConsoleLevel ( Level  l)

Definition at line 154 of file logging.cpp.

◆ setFile()

bool cppxdic::log::Logger::setFile ( const std::string &  path)

Open (or replace) the file sink.

An empty path closes the file sink.

Returns
false if path could not be opened (file sink left closed).

Definition at line 174 of file logging.cpp.

◆ setFileLevel()

void cppxdic::log::Logger::setFileLevel ( Level  l)

Definition at line 159 of file logging.cpp.

◆ setVerboseFormat()

void cppxdic::log::Logger::setVerboseFormat ( bool  on)

Include timestamp + source location in console output too (the file sink always includes them).

Off by default to keep the console readable.

Definition at line 187 of file logging.cpp.

◆ write()

void cppxdic::log::Logger::write ( Level  l,
const char *  file,
int  line,
const std::string &  msg 
)

Emit a fully-formed message (trailing newlines trimmed) at l.

Definition at line 201 of file logging.cpp.


The documentation for this class was generated from the following files: