BetaTrader
A HFT Eco-System
Loading...
Searching...
No Matches
logging::Logger Class Reference

#include <Logger.h>

Collaboration diagram for logging::Logger:
Collaboration graph

Static Public Member Functions

static void Init (const std::string &loggerName="async_logger", const std::string &logFilePath="logs/app.log", const bool enableConsole=true, const bool enableFile=true, const spdlog::level::level_enum globalLevel=spdlog::level::trace, const size_t queueSize=8192, const size_t numThreads=1, size_t maxFileSize=1024 *1024 *300, size_t maxFiles=5, spdlog::sink_ptr customSink=nullptr)
 Initializes the spdlog and sets up the sources and sinks NOTE: Use Shutdown to clean up and dump all queue.
 
static void Shutdown ()
 

Static Private Member Functions

static std::string GenerateTimestampedFilename (const std::string &baseLogPath)
 Generates a timestamped filename.
 

Member Function Documentation

◆ GenerateTimestampedFilename()

static std::string logging::Logger::GenerateTimestampedFilename ( const std::string &  baseLogPath)
inlinestaticprivate

Generates a timestamped filename.

Parameters
baseLogPathBase path (e.g., "logs/app.log")
Returns
Timestamped path (e.g., "logs/app_2025-10-30_14-30-45.log")
Here is the caller graph for this function:

◆ Init()

static void logging::Logger::Init ( const std::string &  loggerName = "async_logger",
const std::string &  logFilePath = "logs/app.log",
const bool  enableConsole = true,
const bool  enableFile = true,
const spdlog::level::level_enum  globalLevel = spdlog::level::trace,
const size_t  queueSize = 8192,
const size_t  numThreads = 1,
size_t  maxFileSize = 1024 * 1024 * 300,
size_t  maxFiles = 5,
spdlog::sink_ptr  customSink = nullptr 
)
inlinestatic

Initializes the spdlog and sets up the sources and sinks NOTE: Use Shutdown to clean up and dump all queue.

Parameters
loggerNameUnique name for the logger
logFilePathPlace to save the log file (timestamp will be added automatically)
enableConsoleto use the console based logging or not
enableFileto use the file based logging or not
globalLevelLevel of log, default is trace
queueSizequeue size of the logging queue
numThreadsnumber of threads used by logger
maxFileSizemaximum file size of the log file
maxFilestotal number of files used by logger
customSinkan optional custom sink to add (e.g., for testing)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Shutdown()

static void logging::Logger::Shutdown ( )
inlinestatic

Clean up the logging threads and dump up the remaining logs in queue

Here is the caller graph for this function:

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