Skip to main content

AVxcelerate Simulation Framework 2025 R2 SP02

simulation_framework::core::logging::LoggingInstance Class Reference

Last update: 19.09.2025

A singleton class to be used for all logging purposes. It can be used to register additional loggers based on the ILogger class to introduce additional logging mechanisms. By default a ConsoleLogger will be registered with each new LoggingInstance. If logging to console is not desired in your use case, you can call ClearLoggers() before adding your custom loggers to disable console logging. More...

#include <logging.h>

Public Types

using ILoggerContainer = std::vector< std::unique_ptr< ILogger > >
 

Public Member Functions

 LoggingInstance (const LoggingInstance &)=delete
 
LoggingInstance & operator= (const LoggingInstance &)=delete
 
void RegisterLogger (std::unique_ptr< ILogger > logger)
 Register a new logger.
 
void ClearLoggers ()
 Remove all currently registered loggers.
 
const ILoggerContainer & GetLoggers () const
 Return a const reference to the container of registered loggers.
 
void Log (LogLevel level, std::string_view message)
 Log a message on the logging interface.
 
void SetLogLevel (LogLevel log_level)
 Set Log level of all registered loggers.
 

Static Public Member Functions

static LoggingInstance & GetInstance ()
 Returns a reference to global singleton logging instance.
 

Detailed Description

A singleton class to be used for all logging purposes. It can be used to register additional loggers based on the ILogger class to introduce additional logging mechanisms. By default a ConsoleLogger will be registered with each new LoggingInstance. If logging to console is not desired in your use case, you can call ClearLoggers() before adding your custom loggers to disable console logging.

Definition at line 27 of file logging.h.

Member Typedef Documentation

◆ ILoggerContainer

using simulation_framework::core::logging::LoggingInstance::ILoggerContainer = std::vector<std::unique_ptr<ILogger> >

Definition at line 30 of file logging.h.

Member Function Documentation

◆ ClearLoggers()

void simulation_framework::core::logging::LoggingInstance::ClearLoggers ( )
inline

Remove all currently registered loggers.

Definition at line 49 of file logging.h.

49{ loggers_.clear(); }

◆ GetInstance()

static LoggingInstance & simulation_framework::core::logging::LoggingInstance::GetInstance ( )
inlinestatic

Returns a reference to global singleton logging instance.

Definition at line 38 of file logging.h.

39 {
40 static LoggingInstance log_instance = LoggingInstance();
41 return log_instance;
42 }

◆ GetLoggers()

const ILoggerContainer & simulation_framework::core::logging::LoggingInstance::GetLoggers ( ) const
inline

Return a const reference to the container of registered loggers.

Definition at line 52 of file logging.h.

52{ return loggers_; }

◆ Log()

void simulation_framework::core::logging::LoggingInstance::Log ( LogLevel  level,
std::string_view  message 
)
inline

Log a message on the logging interface.

Parameters
[in]levelThe log level of the message
[in]messageThe log message

Definition at line 57 of file logging.h.

58 {
59 for (const auto& logger : loggers_)
60 {
61 if (logger)
62 {
63 logger->Log(level, message);
64 }
65 }
66 }

◆ RegisterLogger()

void simulation_framework::core::logging::LoggingInstance::RegisterLogger ( std::unique_ptr< ILogger >  logger)
inline

Register a new logger.

Parameters
[in]loggerThe logger to be registered

Definition at line 46 of file logging.h.

46{ loggers_.push_back(std::move(logger)); }

◆ SetLogLevel()

void simulation_framework::core::logging::LoggingInstance::SetLogLevel ( LogLevel  log_level)
inline

Set Log level of all registered loggers.

Parameters
[in]levelThe log level of the message

Definition at line 70 of file logging.h.

71 {
72 for (const auto& logger : loggers_)
73 {
74 if (logger)
75 {
76 logger->SetCurrentLogLevel(log_level);
77 }
78 }
79 }

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

Connect with Ansys