Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
orbit::utils::Logger Class Reference

#include <Logger.hpp>

Public Types

using Sink = std::function< void(const std::string &line)>
 

Static Public Member Functions

static void init (const std::string &level_str)
 
static void log (LogLevel level, const char *file, int line, const std::string &msg)
 
static void log_fields (LogLevel level, const char *file, int line, const std::string &msg, const LogFields &fields)
 
static void set_format (LogFormat format)
 
static void set_format (const std::string &format)
 Parses "text" or "json" (case-insensitive); anything else keeps the current format.
 
static LogFormat format ()
 
static void set_sink (Sink sink)
 

Static Public Attributes

static LogLevel current_level
 

Static Private Member Functions

static std::string level_to_string (LogLevel level, bool color)
 

Static Private Attributes

static std::mutex log_mutex
 

Member Typedef Documentation

◆ Sink

using orbit::utils::Logger::Sink = std::function<void(const std::string& line)>

Where finished lines go (without the trailing newline). nullptr (the default) writes to stdout.

Member Function Documentation

◆ format()

static LogFormat orbit::utils::Logger::format ( )
static

◆ init()

static void orbit::utils::Logger::init ( const std::string &  level_str)
static

◆ level_to_string()

static std::string orbit::utils::Logger::level_to_string ( LogLevel  level,
bool  color 
)
staticprivate

◆ log()

static void orbit::utils::Logger::log ( LogLevel  level,
const char *  file,
int  line,
const std::string &  msg 
)
static

◆ log_fields()

static void orbit::utils::Logger::log_fields ( LogLevel  level,
const char *  file,
int  line,
const std::string &  msg,
const LogFields &  fields 
)
static

A message with structured fields: JSON keys in Json format, key=value pairs in Text format.

◆ set_format() [1/2]

static void orbit::utils::Logger::set_format ( const std::string &  format)
static

Parses "text" or "json" (case-insensitive); anything else keeps the current format.

◆ set_format() [2/2]

static void orbit::utils::Logger::set_format ( LogFormat  format)
static

◆ set_sink()

static void orbit::utils::Logger::set_sink ( Sink  sink)
static

Member Data Documentation

◆ current_level

LogLevel orbit::utils::Logger::current_level
static

◆ log_mutex

std::mutex orbit::utils::Logger::log_mutex
staticprivate

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