Manager for the loggers. More...
Public Member Functions | |
~LoggerManager () | |
Logger & | cout (const std::string &name, log::Level defualtSeverity=log::Level::LEVEL_NOTSET, log::Visibility defualtVisibility=log::VISIBILITY_NOTSET) |
Logger & | cout (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) |
Logger & | critical (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET) |
Logger & | critical (log::Visibility visibility=log::VISIBILITY_NOTSET) |
Logger & | debug (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET) |
Logger & | debug (log::Visibility visibility=log::VISIBILITY_NOTSET) |
bool | destroy (const std::string &name, bool force=false) |
Logger & | error (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET) |
Logger & | error (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 |
Logger & | info (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET) |
Logger & | info (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) |
Logger & | warning (const std::string &name, log::Visibility visibility=log::VISIBILITY_NOTSET) |
Logger & | warning (log::Visibility visibility=log::VISIBILITY_NOTSET) |
Static Public Member Functions | |
static LoggerManager & | manager () |
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 981 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
-
name is the name of the logger defaultSeverity is the default severity of the messages. defaultVisibility is the default visibility of the messages
- Returns
- An instance of the specified logger.
Definition at line 1049 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
-
defaultSeverity is the default severity of the messages. defaultVisibility is the default visibility of the messages
- Returns
- An instance of the default specified logger.
Definition at line 1025 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
-
name is the name for the logger reset if true the log files will be reset directory is the directory for saving the log files nProcesses is the total number of processes in the communicator rank is the parallel rank in the communicator
Definition at line 1351 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
-
name is the name for the logger reset if true the log files will be reset nProcesses is the total number of processes in the communicator rank is the parallel rank in the communicator
Definition at line 1336 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
-
name is the name of the logger defaultVisibility is the default visibility of the messages
- Returns
- An instance of the specified logger.
Definition at line 1112 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
-
defaultVisibility is the default visibility of the messages
- Returns
- An instance of the default specified logger.
Definition at line 1091 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
-
name is the name of the logger defaultVisibility is the default visibility of the messages
- Returns
- An instance of the specified logger.
Definition at line 1264 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
-
defaultVisibility is the default visibility of the messages
- Returns
- An instance of the default specified logger.
Definition at line 1243 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
-
name is the name of the logger force controls 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 1393 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
-
name is the name of the logger defaultVisibility is the default visibility of the messages
- Returns
- An instance of the specified logger.
Definition at line 1150 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
-
defaultVisibility is the default visibility of the messages
- Returns
- An instance of the default specified logger.
Definition at line 1129 of file logger.cpp.
◆ exists()
bool bitpit::LoggerManager::exists | ( | const std::string & | name | ) | const |
Check if the specified logger exists.
- Parameters
-
name is the name of the logger
- Returns
- True if the logger exists, false otherwise.
Definition at line 1431 of file logger.cpp.
◆ getDefaultDirectory()
std::string bitpit::LoggerManager::getDefaultDirectory | ( | ) | const |
Gets the default logger directory.
- Returns
- The default logger directory.
Definition at line 1612 of file logger.cpp.
◆ getDefaultName()
std::string bitpit::LoggerManager::getDefaultName | ( | ) | const |
Gets the default logger name.
- Returns
- The default logger name.
Definition at line 1602 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 1481 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
-
name is the name of the logger defaultVisibility is the default visibility of the messages
- Returns
- An instance of the specified logger.
Definition at line 1226 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
-
defaultVisibility is the default visibility of the messages
- Returns
- An instance of the default specified logger.
Definition at line 1205 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
-
mode is the mode that will be set reset if true the log files will be reset nProcesses is the total number of processes in the communicator rank is the parallel rank in the communicator
Definition at line 1277 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
-
mode is the mode that will be set reset if true the log files will be reset directory is the default directory for saving the log files nProcesses is the total number of processes in the communicator rank is the parallel rank in the communicator
Definition at line 1292 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
-
mode is the mode that will be set name is the name for the default logger reset if true the log files will be reset directory is the default directory for saving the log files nProcesses is the total number of processes in the communicator rank is the parallel rank in the communicator
Definition at line 1308 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 1446 of file logger.cpp.
◆ manager()
|
static |
Returns an instance of the logger manager.
- Returns
- An instance of the logger manager.
Definition at line 1001 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
-
threshold is the verbosity threshold
Definition at line 1574 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
-
threshold is the verbosity threshold
Definition at line 1590 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
-
mode is the mode that will be set
- Returns
- Returns true if the mode was successfully set, false otherwise.
Definition at line 1465 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
-
threshold is the verbosity threshold
Definition at line 1558 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
-
name is the name of the logger defaultVisibility is the default visibility of the messages
- Returns
- An instance of the specified logger.
Definition at line 1188 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
-
defaultVisibility is the default visibility of the messages
- Returns
- An instance of the default specified logger.
Definition at line 1167 of file logger.cpp.
Member Data Documentation
◆ BITPIT_LOG_DIRECTORY
|
static |
Definition at line 238 of file logger.hpp.
◆ BITPIT_LOG_NAME
|
static |
Definition at line 237 of file logger.hpp.
The documentation for this class was generated from the following files:
- src/common/logger.hpp
- src/common/logger.cpp
