File Logger.h¶
- Copyright
This code is licensed under the 3-clause BSD license.
Copyright ETH Zurich, Laboratory for Physical Chemistry, Reiher Group.
See LICENSE.txt for details.
-
namespace
Scine
This header file contains functions that allow for common notation for common things that can be done at a different degree of derivatives.
This header contains alias definitions defining which classes to use for the different degrees of derivatives.
-
namespace
Utils
-
class
Log
- #include <Logger.h>
Static class for logging.
By default, logging is disabled. Logging can be started with startConsoleLogging() or startFileLogging(). It is possible to have several files for logging.
Public Types
Public Functions
-
Log
() Disabled constructor: this is a static class.
Public Static Functions
-
static void
disableLogging
() This function disables all logging.
-
static void
enableLogging
() This function reenables all logging if disableLogging() was called previously.
-
static void
flush
() Flush the log messages.
It can be that log messages are temporarily stored in a buffer. This forces output to the respective stream.
-
static void
startFileLogging
(std::string filename, severity_level minimalSeverity = defaultMinimalSeverity_, bool autoFlush = false) Start writing log to a file.
- Parameters
filename
: The path to the file to be logged to.minimalSeverity
: Log messages will be written only when their severity is at least as important as this.autoFlush
: Ff true, after each log message the stream will be flushed (at higher computational cost).
-
static void
startConsoleLogging
(severity_level minimalSeverity = defaultMinimalSeverity_) (Re)starts logging to the console.
- Parameters
minimalSeverity
: Log messages will be written only when their severity is at least as important as this.
-
static void
stopConsoleLogging
() Stops logging to the console.
-
static ChainedLogger
trace
() Logging function to log statementes of the severity: trace.
Function returning a logger. Allows direct logging with the left-shift operator:
Log::trace() << "Information to log";
- Return
ChainedLogger The logger to be logged with.
-
static ChainedLogger
debug
() Logging function to log statementes of the severity: debug.
Function returning a logger, the function0 allow dircet logging via the leftshift operator:
Log::debug() << "Information to log";
- Return
ChainedLogger The logger to be logged with.
-
static ChainedLogger
info
() Logging function to log statementes of the severity: info.
Function returning a logger, the function0 allow dircet logging via the leftshift operator:
Log::info() << "Information to log";
- Return
ChainedLogger The logger to be logged with.
-
static ChainedLogger
warning
() Logging function to log statementes of the severity: warning.
Function returning a logger, the function0 allow dircet logging via the leftshift operator:
Log::warning() << "Information to log";
- Return
ChainedLogger The logger to be logged with.
-
static ChainedLogger
error
() Logging function to log statementes of the severity: error.
Function returning a logger, the function0 allow dircet logging via the leftshift operator:
Log::error() << "Information to log";
- Return
ChainedLogger The logger to be logged with.
-
static ChainedLogger
fatal
() Logging function to log statementes of the severity: fatal.
Function returning a logger, the function0 allow dircet logging via the leftshift operator:
Log::fatal() << "Information to log";
- Return
ChainedLogger The logger to be logged with.
-
template<typename
String
>
static voidtrace
(String &&s) Logging function to log statementes of the severity: trace.
- Template Parameters
String
:
- Parameters
s
: The statement to be logged.
-
template<typename
String
>
static voiddebug
(String &&s) Logging function to log statementes of the severity: debug.
- Template Parameters
String
:
- Parameters
s
: The statement to be logged.
-
template<typename
String
>
static voidinfo
(String &&s) Logging function to log statementes of the severity: info.
- Template Parameters
String
:
- Parameters
s
: The statement to be logged.
-
template<typename
String
>
static voidwarning
(String &&s) Logging function to log statementes of the severity: warning.
- Template Parameters
String
:
- Parameters
s
: The statement to be logged.
-
template<typename
String
>
static voiderror
(String &&s) Logging function to log statementes of the severity: error.
- Template Parameters
String
:
- Parameters
s
: The statement to be logged.
-
template<typename
String
>
static voidfatal
(String &&s) Logging function to log statementes of the severity: fatal.
- Template Parameters
String
:
- Parameters
s
: The statement to be logged.
Private Static Attributes
-
std::unique_ptr<Impl>
pImpl_
¶
-
const severity_level
defaultMinimalSeverity_
= severity_level::info¶
-
class
ChainedLogger
Structure allowing to chain output elements to be logged.
The boost macro is called in the destructor to avoid creating one log entry by chained output element.
Public Functions
-
ChainedLogger
(severity_level l) Construct a new ChainedLogger object.
- Parameters
l
: The severty level of this logger.
-
ChainedLogger
(ChainedLogger &&t) Default move constructor.
-
~ChainedLogger
() Custom destructor.
-
template<typename
K
>
std::ostream &operator<<
(K &&k) Overriding the left shift operator.
- Return
std::ostream& The stream logged to.
- Template Parameters
K
: The type of the message.
- Parameters
k
: The message.
-
-
-
class
-
namespace