|
| | FileSink (const FileSink &)=delete |
| | FileSink (const std::filesystem::path &path, LogLevel initialLevel=LogLevel::Info) |
| | Opens path for writing and sets the minimum log level.
|
| | FileSink (FileSink &&)=delete |
| | ~FileSink () override |
| | Flushes and closes the log file.
|
| LogLevel | getLevel () const override |
| | Returns the current minimum log level.
|
| bool | isEnabled (LogLevel level) const override |
| | Returns true if records at level would be emitted.
|
| void | log (std::string_view message, LogLevel level, const std::source_location &location=std::source_location::current()) override |
| | Emits a record at an explicitly specified level.
|
| void | log_critical (std::string_view message, const std::source_location &location=std::source_location::current()) override |
| | Emits a record at Critical level. Explicitly flushes after write.
|
| void | log_debug (std::string_view message, const std::source_location &location=std::source_location::current()) override |
| | Emits a record at Debug level.
|
| void | log_error (std::string_view message, const std::source_location &location=std::source_location::current()) override |
| | Emits a record at Error level.
|
| void | log_info (std::string_view message, const std::source_location &location=std::source_location::current()) override |
| | Emits a record at Info level.
|
| void | log_trace (std::string_view message, const std::source_location &location=std::source_location::current()) override |
| | Emits a record at Trace level.
|
| void | log_warning (std::string_view message, const std::source_location &location=std::source_location::current()) override |
| | Emits a record at Warning level.
|
| FileSink & | operator= (const FileSink &)=delete |
| FileSink & | operator= (FileSink &&)=delete |
| const std::filesystem::path & | path () const |
| | Returns the path of the log file this sink is writing to.
|
| void | setIncludeSourceLocation (bool include) |
| | Controls whether source location (file, line, function) is prepended to each record.
|
| void | setIncludeTimestamp (bool include) |
| | Controls whether a timestamp prefix is prepended to each record.
|
| void | setLevel (LogLevel level) override |
| | Sets the minimum level at which records are emitted.
|
| | Logger (const Logger &)=delete |
| | Logger (Logger &&)=delete |
| virtual | ~Logger ()=default |
| Logger & | operator= (const Logger &)=delete |
| Logger & | operator= (Logger &&)=delete |
|
| static void | critical (std::string_view message, const std::source_location &location=std::source_location::current()) |
| | Emits a record at Critical level via the default logger.
|
| static void | debug (std::string_view message, const std::source_location &location=std::source_location::current()) |
| | Emits a record at Debug level via the default logger.
|
| static Logger & | defaultLogger () |
| | Returns a reference to the registered default logger.
|
| static void | error (std::string_view message, const std::source_location &location=std::source_location::current()) |
| | Emits a record at Error level via the default logger.
|
| static void | info (std::string_view message, const std::source_location &location=std::source_location::current()) |
| | Emits a record at Info level via the default logger.
|
| static void | setDefaultLogger (Logger *logger) |
| | Registers a sink as the process-wide default logger.
|
| static void | trace (std::string_view message, const std::source_location &location=std::source_location::current()) |
| | Emits a record at Trace level via the default logger.
|
| static void | warning (std::string_view message, const std::source_location &location=std::source_location::current()) |
| | Emits a record at Warning level via the default logger.
|
| | Logger ()=default |
Thread-safe logging sink that writes formatted records to a file.
The output file is opened with std::ios::trunc on construction so each process run produces a clean log. If the file cannot be opened the constructor throws std::runtime_error; the logger is never left in a half-open state.
Records below Error level are terminated with '\n'. Critical records receive an explicit flush to maximise visibility before a potential process termination.
auto sink = std::make_shared<Mila::Logging::FileSink>(
static void setDefaultLogger(Logger *logger)
Registers a sink as the process-wide default logger.
Definition Logger.ixx:87
@ Info
Normal operational milestones (model loaded, server ready).
Definition Logger.ixx:44