CppNCorr
C++ ncorr Digital Image Correlation engine
Loading...
Searching...
No Matches
ncorr::log::Logger Class Reference

Process-wide singleton logger. More...

#include <log.h>

Public Member Functions

void set_console_level (Level l)
 
void set_file_level (Level l)
 
Level console_level () const
 
Level file_level () const
 
bool set_file (const std::string &path)
 Open (or replace) the file sink.
 
void set_console_enabled (bool on)
 Enable or disable console output entirely.
 
void set_verbose_format (bool on)
 Include timestamp + source location in console output too (the file sink always includes them).
 
void configure_from_env ()
 Apply NCORR_LOG_LEVEL / NCORR_LOG_FILE / NCORR_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 are trimmed) at l.
 

Static Public Member Functions

static Loggerinstance ()
 

Detailed Description

Process-wide singleton logger.

All members are thread-safe.

Definition at line 51 of file log.h.

Member Function Documentation

◆ configure_from_env()

void ncorr::log::Logger::configure_from_env ( )

Apply NCORR_LOG_LEVEL / NCORR_LOG_FILE / NCORR_LOG_CONSOLE.

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

Definition at line 147 of file log.cpp.

◆ console_level()

Level ncorr::log::Logger::console_level ( ) const

Definition at line 172 of file log.cpp.

◆ enabled()

bool ncorr::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 200 of file log.cpp.

◆ file_level()

Level ncorr::log::Logger::file_level ( ) const

Definition at line 177 of file log.cpp.

◆ instance()

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

Definition at line 131 of file log.cpp.

◆ set_console_enabled()

void ncorr::log::Logger::set_console_enabled ( bool  on)

Enable or disable console output entirely.

Definition at line 190 of file log.cpp.

◆ set_console_level()

void ncorr::log::Logger::set_console_level ( Level  l)

Definition at line 162 of file log.cpp.

◆ set_file()

bool ncorr::log::Logger::set_file ( 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 182 of file log.cpp.

◆ set_file_level()

void ncorr::log::Logger::set_file_level ( Level  l)

Definition at line 167 of file log.cpp.

◆ set_verbose_format()

void ncorr::log::Logger::set_verbose_format ( 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 195 of file log.cpp.

◆ write()

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

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

Definition at line 209 of file log.cpp.


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