62 bool set_file(
const std::string& path);
80 void write(
Level l,
const char* file,
int line,
const std::string& msg);
86 mutable std::mutex mtx_;
89 bool console_enabled_ =
true;
90 bool verbose_format_ =
false;
92 bool env_done_ =
false;
104bool set_file(
const std::string& path);
117 Stream(
Level level,
const char* file,
int line) : level_(level), file_(file), line_(line) {}
123 template <
typename T>
138 std::ostringstream oss_;
155#define NLOG_AT(lvl) \
156 !::ncorr::log::enabled(lvl) \
158 : ::ncorr::log::Voidify() & ::ncorr::log::Stream((lvl), __FILE__, __LINE__)
160#define NLOG_TRACE NLOG_AT(::ncorr::log::Level::Trace)
161#define NLOG_DEBUG NLOG_AT(::ncorr::log::Level::Debug)
162#define NLOG_INFO NLOG_AT(::ncorr::log::Level::Info)
163#define NLOG_WARN NLOG_AT(::ncorr::log::Level::Warn)
164#define NLOG_ERROR NLOG_AT(::ncorr::log::Level::Error)
Process-wide singleton logger.
void configure_from_env()
Apply NCORR_LOG_LEVEL / NCORR_LOG_FILE / NCORR_LOG_CONSOLE.
void set_file_level(Level l)
void write(Level l, const char *file, int line, const std::string &msg)
Emit a fully-formed message (trailing newlines are trimmed) at l.
Level console_level() const
static Logger & instance()
bool enabled(Level l)
True if a message at l would reach any sink.
void set_console_enabled(bool on)
Enable or disable console output entirely.
void set_console_level(Level l)
bool set_file(const std::string &path)
Open (or replace) the file sink.
void set_verbose_format(bool on)
Include timestamp + source location in console output too (the file sink always includes them).
RAII stream builder; flushes its accumulated text to the logger when it is destroyed at the end of th...
Stream & operator=(const Stream &)=delete
Stream(Level level, const char *file, int line)
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 back into a void statement (glog idiom).
bool enabled(Level l)
True if a message at l would be emitted by any sink.
void set_level(Level l)
Set the console threshold (convenience wrapper).
void set_debug(bool on)
Lower the console threshold to Debug when on is true (used to honour the engine's existing debug flag...
Level level_from_string(const std::string &s, Level fallback=Level::Info)
Parse a level name (case-insensitive): trace, debug, info, warn|warning, error, off.
Level
Severity levels, ordered from most to least verbose.
const char * level_name(Level l)
Short, fixed-width display name for a level (e.g. "INFO ").
bool set_file(const std::string &path)
Convenience: open a log file sink (full Debug detail).