The main logger class. More...
#include <Logger.hpp>
Static Public Member Functions | |
static void | configure (const std::string &configurationText, const std::map< std::string, std::string > &placeholders=std::map< std::string, std::string >()) |
Flush all current logging streams and configure the logging system with the supplied configuration text. More... | |
static void | configure (const std::shared_ptr< EnvironmentProperties > &configuration, const std::map< std::string, std::string > &placeholders=std::map< std::string, std::string >()) |
Flush all current logging streams and configure the logging system with the supplied configuration. More... | |
static void | flushAll () |
Flush all logging streams. More... | |
static Logger & | getLogger (std::string_view loggingNamespace) noexcept |
Get a reference to the instance of the logger identified by the supplied namespace. More... | |
static Logger & | globalLogger () |
A predefined reference to the global logger. More... | |
static void | lockConfiguration (bool throwOnReconfigure=false) |
Lock the configuration in order to prevent future reconfiguration. More... | |
static void | registerLoggingStreamFactory (const std::string &scheme, LoggingStreamFactory factory) |
Register a logging stream factory. More... | |
static void | resetConfiguration () |
Flush all current logging streams and reconfigure the logging system to the default configuration. More... | |
Public Member Functions | |
void | debug (const char *message) const |
Log a debug message. More... | |
void | debug (std::string_view message) const |
Log a debug message. More... | |
template<typename ... ObjectT> | |
void | debug (const char *message, const ObjectT &... object) const |
Log a debug message with parameters. More... | |
template<typename ... ObjectT> | |
void | debug (std::string_view message, const ObjectT &... object) const |
Log a debug message with parameters. More... | |
void | debug (const std::function< std::string()> &function) const |
Log a debug message via the supplied function. More... | |
void | debug (const SourceCodeLocation &location, const char *message) const |
Log a debug message and the source code location of the log message call site. More... | |
void | debug (const SourceCodeLocation &location, std::string_view message) const |
Log a debug message and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | debug (const SourceCodeLocation &location, const char *message, const ObjectT &... object) const |
Log a debug message with parameters and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | debug (const SourceCodeLocation &location, std::string_view message, const ObjectT &... object) const |
Log a debug message with parameters and the source code location of the log message call site. More... | |
void | debug (const SourceCodeLocation &location, const std::function< std::string()> &function) const |
Log a debug message via the supplied function and the source code location of the log message call site. More... | |
bool | debugEnabled () const |
Is debug level logging enabled for this logger. More... | |
bool | enabled (LoggingLevel level) const |
Is logging at the specified level enabled for this logger. More... | |
void | error (const char *message) const |
Log an error message. More... | |
void | error (std::string_view message) const |
Log an error message. More... | |
template<typename ... ObjectT> | |
void | error (const char *message, const ObjectT &... object) const |
Log an error message with parameters. More... | |
template<typename ... ObjectT> | |
void | error (std::string_view message, const ObjectT &... object) const |
Log an error message with parameters. More... | |
void | error (const std::function< std::string()> &function) const |
Log a error message via the supplied function. More... | |
void | error (const SourceCodeLocation &location, const char *message) const |
Log an error message and the source code location of the log message call site. More... | |
void | error (const SourceCodeLocation &location, std::string_view message) const |
Log an error message and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | error (const SourceCodeLocation &location, const char *message, const ObjectT &... object) const |
Log an error message with parameters and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | error (const SourceCodeLocation &location, std::string_view message, const ObjectT &... object) const |
Log an error message with parameters and the source code location of the log message call site. More... | |
void | error (const SourceCodeLocation &location, const std::function< std::string()> &function) const |
Log an error message via the supplied function and the source code location of the log message call site. More... | |
bool | errorEnabled () const |
Is error level logging enabled for this logger. More... | |
void | flush () const |
Flush the streams associated with the logger. More... | |
bool | flushes () const noexcept |
Returns true if the logger is auto-flushing. More... | |
std::string | getConfiguration () const |
get the logger's configuration as a string (namespace and properties). More... | |
LoggingLevel | getLevel () const noexcept |
Get the logging level of this logger. More... | |
std::string | getNamespace () const |
Get the logging namespace of this logger. More... | |
void | info (const char *message) const |
Log an info message. More... | |
void | info (std::string_view message) const |
Log an info message. More... | |
template<typename ... ObjectT> | |
void | info (const char *message, const ObjectT &... object) const |
Log an info message with parameters. More... | |
template<typename ... ObjectT> | |
void | info (std::string_view message, const ObjectT &... object) const |
Log an info message with parameters. More... | |
void | info (const std::function< std::string()> &function) const |
Log an info message via the supplied function. More... | |
void | info (const SourceCodeLocation &location, const char *message) const |
Log an info message and the source code location of the log message call site. More... | |
void | info (const SourceCodeLocation &location, std::string_view message) const |
Log an info message and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | info (const SourceCodeLocation &location, const char *message, const ObjectT &... object) const |
Log an info message with parameters and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | info (const SourceCodeLocation &location, std::string_view message, const ObjectT &... object) const |
Log an info message with parameters and the source code location of the log message call site. More... | |
void | info (const SourceCodeLocation &location, const std::function< std::string()> &function) const |
Log an info message via the supplied function and the source code location of the log message call site. More... | |
bool | infoEnabled () const |
Is info level logging enabled for this logger. More... | |
void | log (LoggingLevel specifiedLevel, const char *message) const |
Log a message. More... | |
void | log (LoggingLevel specifiedLevel, std::string_view message) const |
Log a message. More... | |
template<typename ... ObjectT> | |
void | log (LoggingLevel specifiedLevel, const char *message, const ObjectT &... object) const |
Log a message with parameters. More... | |
template<typename ... ObjectT> | |
void | log (LoggingLevel specifiedLevel, std::string_view message, const ObjectT &... object) const |
Log a message with parameters. More... | |
void | log (LoggingLevel specifiedLevel, const std::function< std::string()> &function) const |
Log a error message via the supplied function. More... | |
void | log (LoggingLevel specifiedLevel, const SourceCodeLocation &location, const char *message) const |
Log an error message and the source code location of the log message call site. More... | |
void | log (LoggingLevel specifiedLevel, const SourceCodeLocation &location, std::string_view message) const |
Log an error message and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | log (LoggingLevel specifiedLevel, const SourceCodeLocation &location, const char *message, const ObjectT &... object) const |
Log an error message with parameters and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | log (LoggingLevel specifiedLevel, const SourceCodeLocation &location, std::string_view message, const ObjectT &... object) const |
Log an error message with parameters and the source code location of the log message call site. More... | |
void | log (LoggingLevel specifiedLevel, const SourceCodeLocation &location, const std::function< std::string()> &function) const |
Log an error message via the supplied function and the source code location of the log message call site. More... | |
bool | operator== (const Logger &logger) const |
Compare two loggers for equality. More... | |
void | trace (const char *message) const |
Log a trace message. More... | |
void | trace (std::string_view message) const |
Log a trace message. More... | |
template<typename ... ObjectT> | |
void | trace (const char *message, const ObjectT &... object) const |
Log a trace message with parameters. More... | |
template<typename ... ObjectT> | |
void | trace (std::string_view message, const ObjectT &... object) const |
Log a trace message with parameters. More... | |
void | trace (const std::function< std::string()> &function) const |
Log a trace message via the supplied function. More... | |
void | trace (const SourceCodeLocation &location, const char *message) const |
Log a trace message and the source code location of the log message call site. More... | |
void | trace (const SourceCodeLocation &location, std::string_view message) const |
Log a trace message and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | trace (const SourceCodeLocation &location, const char *message, const ObjectT &... object) const |
Log a trace message with parameters and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | trace (const SourceCodeLocation &location, std::string_view message, const ObjectT &... object) const |
Log a trace message with parameters and the source code location of the log message call site. More... | |
void | trace (const SourceCodeLocation &location, const std::function< std::string()> &function) const |
Log a trace message via the supplied function and the source code location of the log message call site. More... | |
bool | traceEnabled () const |
Is trace level logging enabled for this logger. More... | |
void | warn (const char *message) const |
Log a warn message. More... | |
void | warn (std::string_view message) const |
Log a warn message. More... | |
template<typename ... ObjectT> | |
void | warn (const char *message, const ObjectT &... object) const |
Log a warn message with parameters. More... | |
template<typename ... ObjectT> | |
void | warn (std::string_view message, const ObjectT &... object) const |
Log a warn message with parameters. More... | |
void | warn (const std::function< std::string()> &function) const |
Log a warn message via the supplied function. More... | |
void | warn (const SourceCodeLocation &location, const char *message) const |
Log a warn message and the source code location of the log message call site. More... | |
void | warn (const SourceCodeLocation &location, std::string_view message) const |
Log a warn message and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | warn (const SourceCodeLocation &location, const char *message, const ObjectT &... object) const |
Log a warn message with parameters and the source code location of the log message call site. More... | |
template<typename ... ObjectT> | |
void | warn (const SourceCodeLocation &location, std::string_view message, const ObjectT &... object) const |
Log a warn message with parameters and the source code location of the log message call site. More... | |
void | warn (const SourceCodeLocation &location, const std::function< std::string()> &function) const |
Log a warn message via the supplied function and the source code location of the log message call site. More... | |
bool | warnEnabled () const |
Is warn level logging enabled for this logger. More... | |
The main logger class.
All interaction with the logging system occurs through static methods in this class or instance methods called on Logger references obtained from the static Logger::getLogger method.
|
static |
Flush all current logging streams and configure the logging system with the supplied configuration text.
Any placeholders supplied in the placeholders map will be used to expand any macros found in the configuration text.
This call will obtain a lock on the logging system mutex.
configurationText | the unparsed logging configuration |
placeholders | zero or more placeholders to be used to expand any macros present in the string value properties |
LoggingConfigurationException | if logging reconfiguration has previously been locked. |
|
static |
Flush all current logging streams and configure the logging system with the supplied configuration.
Any placeholders supplied in the placeholders map will be used to expand any macros found in the configuration.
This call will obtain a lock on the logging system mutex.
configuration | the pre-parsed logging configuration (normally from the injector) |
placeholders | zero or more placeholders to be used to expand any macros present in the string value properties |
LoggingConfigurationException | if logging reconfiguration has previously been locked. |
|
inline |
Log a debug message.
|
inline |
Log a debug message.
|
inline |
Log a debug message with parameters.
|
inline |
Log a debug message with parameters.
|
inline |
Log a debug message via the supplied function.
|
inline |
Log a debug message and the source code location of the log message call site.
|
inline |
Log a debug message and the source code location of the log message call site.
|
inline |
Log a debug message with parameters and the source code location of the log message call site.
|
inline |
Log a debug message with parameters and the source code location of the log message call site.
|
inline |
Log a debug message via the supplied function and the source code location of the log message call site.
|
inline |
Is debug level logging enabled for this logger.
|
inline |
Is logging at the specified level enabled for this logger.
|
inline |
Log an error message.
|
inline |
Log an error message.
|
inline |
Log an error message with parameters.
|
inline |
Log an error message with parameters.
|
inline |
Log a error message via the supplied function.
|
inline |
Log an error message and the source code location of the log message call site.
|
inline |
Log an error message and the source code location of the log message call site.
|
inline |
Log an error message with parameters and the source code location of the log message call site.
|
inline |
Log an error message with parameters and the source code location of the log message call site.
|
inline |
Log an error message via the supplied function and the source code location of the log message call site.
|
inline |
Is error level logging enabled for this logger.
void flush | ( | ) | const |
Flush the streams associated with the logger.
The logger may already be configured to flush after every message.
If the logging system is reconfigured during a call to flush, it is not guaranteed that all or any of the streams will be flushed.
|
static |
Flush all logging streams.
This call will obtain a lock on the logging mutex.
|
inlinenoexcept |
Returns true if the logger is auto-flushing.
std::string getConfiguration | ( | ) | const |
get the logger's configuration as a string (namespace and properties).
This call will obtain a lock on the logging system mutex.
|
inlinenoexcept |
Get the logging level of this logger.
|
staticnoexcept |
Get a reference to the instance of the logger identified by the supplied namespace.
If the logger instance cannot be obtained, the null logger will be returned and an error message will be logged to stderr.
This call will obtain a lock on the logging system mutex.
loggingNamespace | the logger's logging namespace |
|
inline |
Get the logging namespace of this logger.
|
static |
A predefined reference to the global logger.
|
inline |
Log an info message.
|
inline |
Log an info message.
|
inline |
Log an info message with parameters.
|
inline |
Log an info message with parameters.
|
inline |
Log an info message via the supplied function.
|
inline |
Log an info message and the source code location of the log message call site.
|
inline |
Log an info message and the source code location of the log message call site.
|
inline |
Log an info message with parameters and the source code location of the log message call site.
|
inline |
Log an info message with parameters and the source code location of the log message call site.
|
inline |
Log an info message via the supplied function and the source code location of the log message call site.
|
inline |
Is info level logging enabled for this logger.
|
static |
Lock the configuration in order to prevent future reconfiguration.
This call will obtain a lock on the logging system mutex.
throwOnReconfigure | determines whether a subsequent call to the configure method will result in an exception (LoggingConfigurationException) being thrown or whether such a call will be silently ignored. |
|
inline |
Log a message.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log a message.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log a message with parameters.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log a message with parameters.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log a error message via the supplied function.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log an error message and the source code location of the log message call site.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log an error message and the source code location of the log message call site.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log an error message with parameters and the source code location of the log message call site.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log an error message with parameters and the source code location of the log message call site.
The error will be logged at the specified level if the level is enabled.
|
inline |
Log an error message via the supplied function and the source code location of the log message call site.
The error will be logged at the specified level if the level is enabled.
|
inline |
Compare two loggers for equality.
|
static |
Register a logging stream factory.
See LoggingStream for information on creating logging stream plugins.
|
static |
Flush all current logging streams and reconfigure the logging system to the default configuration.
The default configuration will be the default configuration plus the cascade of the configuration obtained from the balau-logging.hconf file if the file exists.
This call will obtain a lock on the logging system mutex.
LoggingConfigurationException | if logging reconfiguration has previously been locked. |
|
inline |
Log a trace message.
|
inline |
Log a trace message.
|
inline |
Log a trace message with parameters.
|
inline |
Log a trace message with parameters.
|
inline |
Log a trace message via the supplied function.
|
inline |
Log a trace message and the source code location of the log message call site.
|
inline |
Log a trace message and the source code location of the log message call site.
|
inline |
Log a trace message with parameters and the source code location of the log message call site.
|
inline |
Log a trace message with parameters and the source code location of the log message call site.
|
inline |
Log a trace message via the supplied function and the source code location of the log message call site.
|
inline |
Is trace level logging enabled for this logger.
|
inline |
Log a warn message.
|
inline |
Log a warn message.
|
inline |
Log a warn message with parameters.
|
inline |
Log a warn message with parameters.
|
inline |
Log a warn message via the supplied function.
|
inline |
Log a warn message and the source code location of the log message call site.
|
inline |
Log a warn message and the source code location of the log message call site.
|
inline |
Log a warn message with parameters and the source code location of the log message call site.
|
inline |
Log a warn message with parameters and the source code location of the log message call site.
|
inline |
Log a warn message via the supplied function and the source code location of the log message call site.
|
inline |
Is warn level logging enabled for this logger.