27#ifndef CPPXDIC_LOGGING_H
28#define CPPXDIC_LOGGING_H
63 bool setFile(
const std::string& path);
81 void write(
Level l,
const char* file,
int line,
const std::string& msg);
87 mutable std::mutex mtx_;
90 bool console_enabled_ =
true;
91 bool verbose_format_ =
false;
93 bool env_done_ =
false;
114bool setFile(
const std::string& path);
125 Stream(
Level level,
const char* file,
int line) : level_(level), file_(file), line_(line) {}
131 template <
typename T>
146 std::ostringstream oss_;
164 !::cppxdic::log::enabled(lvl) \
166 : ::cppxdic::log::Voidify() & ::cppxdic::log::Stream((lvl), __FILE__, __LINE__)
168#define LOG_TRACE LOG_AT(::cppxdic::log::Level::Trace)
169#define LOG_DEBUG LOG_AT(::cppxdic::log::Level::Debug)
170#define LOG_INFO LOG_AT(::cppxdic::log::Level::Info)
171#define LOG_WARN LOG_AT(::cppxdic::log::Level::Warn)
172#define LOG_ERROR LOG_AT(::cppxdic::log::Level::Error)
Process-wide singleton logger.
void setVerboseFormat(bool on)
Include timestamp + source location in console output too (the file sink always includes them).
void setFileLevel(Level l)
void setConsoleLevel(Level l)
bool setFile(const std::string &path)
Open (or replace) the file sink.
bool enabled(Level l)
True if a message at l would reach any sink.
Level consoleLevel() const
void configureFromEnv()
Apply CPPXDIC_LOG_LEVEL / CPPXDIC_LOG_FILE / CPPXDIC_LOG_CONSOLE.
static Logger & instance()
void write(Level l, const char *file, int line, const std::string &msg)
Emit a fully-formed message (trailing newlines trimmed) at l.
void setConsoleEnabled(bool on)
Enable or disable console output entirely.
RAII stream builder; flushes accumulated text to the logger when it is destroyed at the end of the fu...
Stream(Level level, const char *file, int line)
Stream & operator=(const Stream &)=delete
Stream(const Stream &)=delete
Stream & operator<<(const T &v)
Stream & operator<<(std::ostream &(*manip)(std::ostream &))
Support stream manipulators such as std::endl / std::setprecision.
Helper that turns the conditional logging expression into a void statement (glog idiom).
void configureFromOptions(const Options &opts)
Apply env vars, then the supplied options (CLI/config), to the singleton.
void setLevel(Level l)
Convenience accessors.
Level
Severity levels, ordered from most to least verbose.
bool setFile(const std::string &path)
Level levelFromString(const std::string &s, Level fallback=Level::Info)
Parse a level name (case-insensitive): trace, debug, info, warn|warning, error, off.
const char * levelName(Level l)
Short, fixed-width display name for a level (e.g. "INFO ").
DataSerializer - Abstract base class for format-agnostic DIC data I/O.
Aggregated options resolved from env/config/CLI, applied in one call.
bool console_level_set
true if an explicit level was chosen
std::string log_file
empty = no file sink
int verbose
-V count: lowers threshold per step
bool debug
debug mode (Debug level + verbose format)
bool quiet
force console threshold up to Warn