DiaDes  0.1
DIAgnosis of Discrete-Event System
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Diades::Utils::LoggerFactory Class Reference

#include <Logger.hh>

Public Member Functions

const string & getLabel (LogLevel level) const
 
 ~LoggerFactory ()
 
Logger getLogger (const string &name)
 
Logger getRootLogger ()
 

Static Public Member Functions

static void destroy ()
 
static LoggerFactoryfactory ()
 

Protected Member Functions

 LoggerFactory ()
 

Private Attributes

std::shared_ptr< LoggerData_defaultLogger
 
unordered_map< string, std::shared_ptr< LoggerData > > _loggers
 
vector< string > _levelLabels
 

Static Private Attributes

static LoggerFactory_instance
 

Friends

ostream & operator<< (ostream &os, const LoggerFactory &loggers)
 

Detailed Description

This class manages the set of available Loggers. At any time, the factory manages the default Logger. It can also manage another set of Loggers. Each Logger has then a name. The factory is unique (singleton pattern).

Definition at line 229 of file Logger.hh.

Constructor & Destructor Documentation

◆ LoggerFactory()

Diades::Utils::LoggerFactory::LoggerFactory ( )
protected

protected default constructor

◆ ~LoggerFactory()

Diades::Utils::LoggerFactory::~LoggerFactory ( )

Destructor

Member Function Documentation

◆ destroy()

static void Diades::Utils::LoggerFactory::destroy ( )
static

Destroy the Logger factory.

Note
Should be used only at the end of the process for proper memory management. Be aware that the use of the function destroys all the allocated Loggers

Referenced by clean(), and main().

◆ factory()

static LoggerFactory* Diades::Utils::LoggerFactory::factory ( )
static
Returns
the unique LoggerFactory

◆ getLabel()

const string& Diades::Utils::LoggerFactory::getLabel ( LogLevel  level) const
inline
Returns
the label associated to the level

Definition at line 265 of file Logger.hh.

◆ getLogger()

Logger Diades::Utils::LoggerFactory::getLogger ( const string &  name)
inline

The logger with a given name

Parameters
namethe name of the Logger
Returns
the Logger with the name 'name'

Definition at line 291 of file Logger.hh.

◆ getRootLogger()

Logger Diades::Utils::LoggerFactory::getRootLogger ( )
inline

The default logger

Returns
the default logger

Definition at line 309 of file Logger.hh.

References Diades::Utils::operator<<().

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  os,
const LoggerFactory loggers 
)
friend

Output stream operator

Parameters
osoutput stream
loggersthe LoggerFactory
Returns
the updated output stream

Member Data Documentation

◆ _defaultLogger

std::shared_ptr<LoggerData> Diades::Utils::LoggerFactory::_defaultLogger
private

Definition at line 233 of file Logger.hh.

◆ _instance

LoggerFactory* Diades::Utils::LoggerFactory::_instance
staticprivate

Definition at line 232 of file Logger.hh.

◆ _levelLabels

vector<string> Diades::Utils::LoggerFactory::_levelLabels
private

Definition at line 235 of file Logger.hh.

◆ _loggers

unordered_map<string, std::shared_ptr<LoggerData> > Diades::Utils::LoggerFactory::_loggers
private

Definition at line 234 of file Logger.hh.


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