Toast Engine
Loading...
Searching...
No Matches
logging::Logger Class Reference

Public Member Functions

 ~Logger () noexcept
 Clean shutdown: flushes remaining logs and closes the connection.
 Logger (const Logger &)=delete
 Logger (Logger &&)=delete
auto operator= (const Logger &) -> Logger &=delete
auto operator= (Logger &&) -> Logger &=delete

Static Public Member Functions

static auto create () noexcept -> std::unique_ptr< Logger >
 Set up the global logger instance, gives ownership to the caller.
static void log (std::string_view file, unsigned line, char severity, std::string_view sink, std::string_view message)
 Entry point for all engine logs.

Member Function Documentation

◆ create()

auto logging::Logger::create ( ) -> std::unique_ptr< Logger >
staticnoexcept

Set up the global logger instance, gives ownership to the caller.

Returns
A unique_ptr that manages the logger's lifetime
Note
This function asserts it will only be called once

◆ log()

void logging::Logger::log ( std::string_view file,
unsigned line,
char severity,
std::string_view sink,
std::string_view message )
static

Entry point for all engine logs.

Thread-safe. It pushes the log to a local queue and signals a background task to handle the actual network I/O

Here is the caller graph for this function:

Member Data Documentation

◆ drain_pending

std::atomic<bool> logging::Logger::drain_pending = false

Prevents multiple background jobs from fighting over the same socket.

We use an atomic flag to ensure only one 'drain' job is scheduled at a time, avoiding unnecessary context switches and thread contention.


The documentation for this class was generated from the following files:
  • engine/src/toast/logger.hpp
  • engine/src/toast/logger.cpp