Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
bitpit::LoggerManager Class Reference

Manager for the loggers. More...

Public Member Functions

 ~LoggerManager ()
 
Loggercout (const std::string &name, log::Level defualtSeverity=log::Level::LEVEL_NOTSET, log::Visibility defualtVisibility=log::VISIBILITY_NOTSET)
 
Loggercout (log::Level defualtSeverity=log::Level::LEVEL_NOTSET, log::Visibility defualtVisibility=log::VISIBILITY_NOTSET)
 
void create (const std::string &name, bool reset, const std::string &directory, int nProcesses=1, int rank=0)
 
void create (const std::string &name, bool reset=false, int nProcesses=1, int rank=0)
 
Loggercritical (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET)
 
Loggercritical (log::Visibility visibility=log::VISIBILITY_NOTSET)
 
Loggerdebug (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET)
 
Loggerdebug (log::Visibility visibility=log::VISIBILITY_NOTSET)
 
bool destroy (const std::string &name, bool force=false)
 
Loggererror (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET)
 
Loggererror (log::Visibility visibility=log::VISIBILITY_NOTSET)
 
bool exists (const std::string &name) const
 
std::string getDefaultDirectory () const
 
std::string getDefaultName () const
 
log::Mode getMode () const
 
Loggerinfo (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET)
 
Loggerinfo (log::Visibility visibility=log::VISIBILITY_NOTSET)
 
void initialize (log::Mode mode, bool reset, int nProcesses, int rank)
 
void initialize (log::Mode mode, bool reset=false, const std::string &directory=BITPIT_LOG_DIRECTORY, int nProcesses=1, int rank=0)
 
void initialize (log::Mode mode, const std::string &name, bool reset=false, const std::string &directory=BITPIT_LOG_DIRECTORY, int nProcesses=1, int rank=0)
 
bool isInitialized () const
 
void setConsoleVerbosity (log::Level threshold)
 
void setFileVerbosity (log::Level threshold)
 
bool setMode (log::Mode mode)
 
void setVerbosities (log::Level threshold)
 
Loggerwarning (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET)
 
Loggerwarning (log::Visibility visibility=log::VISIBILITY_NOTSET)
 

Static Public Member Functions

static LoggerManagermanager ()
 

Static Public Attributes

static BITPIT_PUBLIC_API std::string BITPIT_LOG_DIRECTORY = "."
 
static BITPIT_PUBLIC_API std::string BITPIT_LOG_NAME = "bitpit"
 

Detailed Description

Manager for the loggers.

This class implements a manager for the loggers. The manager allows the different loggers to work together.

Definition at line 233 of file logger.hpp.

Constructor & Destructor Documentation

◆ ~LoggerManager()

bitpit::LoggerManager::~LoggerManager ( )

Destructor.

Definition at line 972 of file logger.cpp.

Member Function Documentation

◆ cout() [1/2]

Logger & bitpit::LoggerManager::cout ( const std::string & name,
log::Level defaultSeverity = log::Level::LEVEL_NOTSET,
log::Visibility defaultVisibility = log::VISIBILITY_NOTSET )

Returns an instance of the specified logger.

This function returns an instance of the specified logger. If the logger does not exists a new instance will be created.

The default severity of the messages will be set to the specified level, if no default severity is specified, the default severity will remain unaltered.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
nameis the name of the logger
defaultSeverityis the default severity of the messages.
defaultVisibilityis the default visibility of the messages
Returns
An instance of the specified logger.

Definition at line 1040 of file logger.cpp.

◆ cout() [2/2]

Logger & bitpit::LoggerManager::cout ( log::Level defaultSeverity = log::Level::LEVEL_NOTSET,
log::Visibility defaultVisibility = log::VISIBILITY_NOTSET )

Returns an instance of default logger.

The default severity of the messages will be set to the specified level, if no default severity is specified, the default severity will remain unaltered.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
defaultSeverityis the default severity of the messages.
defaultVisibilityis the default visibility of the messages
Returns
An instance of the default specified logger.

Definition at line 1016 of file logger.cpp.

◆ create() [1/2]

void bitpit::LoggerManager::create ( const std::string & name,
bool reset,
const std::string & directory,
int nProcesses = 1,
int rank = 0 )

Creates a new logger.

Parameters
nameis the name for the logger
resetif true the log files will be reset
directoryis the directory for saving the log files
nProcessesis the total number of processes in the communicator
rankis the parallel rank in the communicator

Definition at line 1342 of file logger.cpp.

◆ create() [2/2]

void bitpit::LoggerManager::create ( const std::string & name,
bool reset = false,
int nProcesses = 1,
int rank = 0 )

Creates a new logger.

Parameters
nameis the name for the logger
resetif true the log files will be reset
nProcessesis the total number of processes in the communicator
rankis the parallel rank in the communicator

Definition at line 1327 of file logger.cpp.

◆ critical() [1/2]

Logger & bitpit::LoggerManager::critical ( const std::string & name,
log::Visibility defaultVisibility = log::VISIBILITY_NOTSET )

Returns an instance of the specified logger.

This function returns an instance of the specified logger. If the logger does not exists a new instance will be created.

The default severity of the messages will be set to the CRITICAL level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
nameis the name of the logger
defaultVisibilityis the default visibility of the messages
Returns
An instance of the specified logger.

Definition at line 1103 of file logger.cpp.

◆ critical() [2/2]

Logger & bitpit::LoggerManager::critical ( log::Visibility defaultVisibility = log::VISIBILITY_NOTSET)

Returns an instance of default logger.

The default severity of the messages will be set to the CRITICAL level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
defaultVisibilityis the default visibility of the messages
Returns
An instance of the default specified logger.

Definition at line 1082 of file logger.cpp.

◆ debug() [1/2]

Logger & bitpit::LoggerManager::debug ( const std::string & name,
log::Visibility defaultVisibility = log::VISIBILITY_NOTSET )

Returns an instance of the specified logger.

This function returns an instance of the specified logger. If the logger does not exists a new instance will be created.

The default severity of the messages will be set to the DEBUG level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
nameis the name of the logger
defaultVisibilityis the default visibility of the messages
Returns
An instance of the specified logger.

Definition at line 1255 of file logger.cpp.

◆ debug() [2/2]

Logger & bitpit::LoggerManager::debug ( log::Visibility defaultVisibility = log::VISIBILITY_NOTSET)

Returns an instance of default logger.

The default severity of the messages will be set to the DEBUG level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
defaultVisibilityis the default visibility of the messages
Returns
An instance of the default specified logger.

Definition at line 1234 of file logger.cpp.

◆ destroy()

bool bitpit::LoggerManager::destroy ( const std::string & name,
bool force = false )

Destroys the specified logger.

The logger can be shared among different users, a logger is destroyed only if it has no users.

Parameters
nameis the name of the logger
forcecontrols if the logger will be destroyed also if it still has users
Returns
True if the logger has been destroyed, false otherwise.

Definition at line 1384 of file logger.cpp.

◆ error() [1/2]

Logger & bitpit::LoggerManager::error ( const std::string & name,
log::Visibility defaultVisibility = log::VISIBILITY_NOTSET )

Returns an instance of the specified logger.

This function returns an instance of the specified logger. If the logger does not exists a new instance will be created.

The default severity of the messages will be set to the ERROR level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
nameis the name of the logger
defaultVisibilityis the default visibility of the messages
Returns
An instance of the specified logger.

Definition at line 1141 of file logger.cpp.

◆ error() [2/2]

Logger & bitpit::LoggerManager::error ( log::Visibility defaultVisibility = log::VISIBILITY_NOTSET)

Returns an instance of default logger.

The default severity of the messages will be set to the ERROR level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
defaultVisibilityis the default visibility of the messages
Returns
An instance of the default specified logger.

Definition at line 1120 of file logger.cpp.

◆ exists()

bool bitpit::LoggerManager::exists ( const std::string & name) const

Check if the specified logger exists.

Parameters
nameis the name of the logger
Returns
True if the logger exists, false otherwise.

Definition at line 1422 of file logger.cpp.

◆ getDefaultDirectory()

std::string bitpit::LoggerManager::getDefaultDirectory ( ) const

Gets the default logger directory.

Returns
The default logger directory.

Definition at line 1603 of file logger.cpp.

◆ getDefaultName()

std::string bitpit::LoggerManager::getDefaultName ( ) const

Gets the default logger name.

Returns
The default logger name.

Definition at line 1593 of file logger.cpp.

◆ getMode()

log::Mode bitpit::LoggerManager::getMode ( ) const

Get the operational mode of the logger manager.

Returns
The operational mode of the logger manager.

Definition at line 1472 of file logger.cpp.

◆ info() [1/2]

Logger & bitpit::LoggerManager::info ( const std::string & name,
log::Visibility defaultVisibility = log::VISIBILITY_NOTSET )

Returns an instance of the specified logger.

This function returns an instance of the specified logger. If the logger does not exists a new instance will be created.

The default severity of the messages will be set to the INFO level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
nameis the name of the logger
defaultVisibilityis the default visibility of the messages
Returns
An instance of the specified logger.

Definition at line 1217 of file logger.cpp.

◆ info() [2/2]

Logger & bitpit::LoggerManager::info ( log::Visibility defaultVisibility = log::VISIBILITY_NOTSET)

Returns an instance of default logger.

The default severity of the messages will be set to the INFO level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
defaultVisibilityis the default visibility of the messages
Returns
An instance of the default specified logger.

Definition at line 1196 of file logger.cpp.

◆ initialize() [1/3]

void bitpit::LoggerManager::initialize ( log::Mode mode,
bool reset,
int nProcesses,
int rank )

Initializes the log manager.

Parameters
modeis the mode that will be set
resetif true the log files will be reset
nProcessesis the total number of processes in the communicator
rankis the parallel rank in the communicator

Definition at line 1268 of file logger.cpp.

◆ initialize() [2/3]

void bitpit::LoggerManager::initialize ( log::Mode mode,
bool reset = false,
const std::string & directory = BITPIT_LOG_DIRECTORY,
int nProcesses = 1,
int rank = 0 )

Initializes the log manager.

Parameters
modeis the mode that will be set
resetif true the log files will be reset
directoryis the default directory for saving the log files
nProcessesis the total number of processes in the communicator
rankis the parallel rank in the communicator

Definition at line 1283 of file logger.cpp.

◆ initialize() [3/3]

void bitpit::LoggerManager::initialize ( log::Mode mode,
const std::string & name,
bool reset = false,
const std::string & directory = BITPIT_LOG_DIRECTORY,
int nProcesses = 1,
int rank = 0 )

Initializes the log manager.

Parameters
modeis the mode that will be set
nameis the name for the default logger
resetif true the log files will be reset
directoryis the default directory for saving the log files
nProcessesis the total number of processes in the communicator
rankis the parallel rank in the communicator

Definition at line 1299 of file logger.cpp.

◆ isInitialized()

bool bitpit::LoggerManager::isInitialized ( ) const

Checks if the logger manager has been initialized.

Explicit initialization of the manager is done using the function 'initialize', implicit initialization happens the first time a logger is created.

Returns
Returns true if the logger manager has been initialized, false otherwise.

Definition at line 1437 of file logger.cpp.

◆ manager()

LoggerManager & bitpit::LoggerManager::manager ( )
static

Returns an instance of the logger manager.

Returns
An instance of the logger manager.

Definition at line 992 of file logger.cpp.

◆ setConsoleVerbosity()

void bitpit::LoggerManager::setConsoleVerbosity ( log::Level threshold)

Sets the verbosity threshold for messages printed on the console.

Logging messages which are less severe than the verbosity threshold will be ignored; logging messages which have severity equal to the verbosity threshold or higher will be printed.

Parameters
thresholdis the verbosity threshold

Definition at line 1565 of file logger.cpp.

◆ setFileVerbosity()

void bitpit::LoggerManager::setFileVerbosity ( log::Level threshold)

Sets the verbosity threshold for messages printed on the log file.

Logging messages which are less severe than the verbosity threshold will be ignored; logging messages which have severity equal to the verbosity threshold or higher will be printed.

Parameters
thresholdis the verbosity threshold

Definition at line 1581 of file logger.cpp.

◆ setMode()

bool bitpit::LoggerManager::setMode ( log::Mode mode)

Set the operational mode of the logger manager.

There are two possible modes:

  • when the manager operates in SEPARATE mode, each logger will write the messages in its own file;
  • when the manager operates in COMBINED mode, all the loggers will write the messages on the same file.

The mode has to be set before creating the first logger.

Parameters
modeis the mode that will be set
Returns
Returns true if the mode was successfully set, false otherwise.

Definition at line 1456 of file logger.cpp.

◆ setVerbosities()

void bitpit::LoggerManager::setVerbosities ( log::Level threshold)

Sets the verbosity threshold for messages printed on the console and on the log file.

Logging messages which are less severe than the verbosity threshold will be ignored; logging messages which have severity equal to the verbosity threshold or higher will be printed.

Parameters
thresholdis the verbosity threshold

Definition at line 1549 of file logger.cpp.

◆ warning() [1/2]

Logger & bitpit::LoggerManager::warning ( const std::string & name,
log::Visibility defaultVisibility = log::VISIBILITY_NOTSET )

Returns an instance of the specified logger.

This function returns an instance of the specified logger. If the logger does not exists a new instance will be created.

The default severity of the messages will be set to the WARNING level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
nameis the name of the logger
defaultVisibilityis the default visibility of the messages
Returns
An instance of the specified logger.

Definition at line 1179 of file logger.cpp.

◆ warning() [2/2]

Logger & bitpit::LoggerManager::warning ( log::Visibility defaultVisibility = log::VISIBILITY_NOTSET)

Returns an instance of default logger.

The default severity of the messages will be set to the WARNING level.

The default visibility of the messages will be set to the specified level, if no default visibility is specified, the default visibility will remain unaltered.

Parameters
defaultVisibilityis the default visibility of the messages
Returns
An instance of the default specified logger.

Definition at line 1158 of file logger.cpp.

Member Data Documentation

◆ BITPIT_LOG_DIRECTORY

std::string bitpit::LoggerManager::BITPIT_LOG_DIRECTORY = "."
static

Definition at line 238 of file logger.hpp.

◆ BITPIT_LOG_NAME

std::string bitpit::LoggerManager::BITPIT_LOG_NAME = "bitpit"
static

Definition at line 237 of file logger.hpp.


The documentation for this class was generated from the following files:
--- layout: doxygen_footer ---