Template Class Logger¶
Defined in File logger.hpp
Class Documentation¶
-
template<LogLevel
MinLevel
, size_tBufferSize
, typenameLockPolicy
>
classripple
::
Logger
¶ Simple logger class, which logs messages when the level of the message is more tha the MinLevel.
The messages are buffered in a buffer of BufferSize, and if a message wont fit in the buffer, the buffer is flushed.
This logger is not designed to be high-performance, since in release the only messages that will be logged in the fast path are error messages, and info messages will be in the slow path, so safety and flexibility are more important.
The logger uses an instance of the locking policy to lock when logging.
- Template Parameters
MinLevel
: The minimum level for message logging.BufferSize
: The size of the message buffer.LockPolicy
: The locking polcity for the lock.
Public Functions
-
~Logger
()¶ Flushes pending logs in the stream and closes the logging file.
-
auto
operator=
(Logger&&) noexcept -> Logger& = default¶ Delete move assignment, since we can only have a single logger.
-
Logger
() = delete¶ Deleted , create through create().
-
auto
operator=
(const Logger&) = delete¶ Delete copy assignment, since we can only have a single logger.
-
auto
flush
() -> void¶ Flushes the pending messages in the logger to the logging file.
Note that this claims the mutex to perform the write, so it should only be called to flush the logger if a termination happens.
-
template<LogLevel
L
, VoidLogEnable<L> = 0>
autolog
(const std::string &message) noexcept -> void¶ Never logs the message, which should already be formatted.
This overload is enabled if the level L is more than the level of the logger, and will be compiled away.
- Parameters
message
: The message to log.
- Template Parameters
L
: The log level for the message.
-
template<LogLevel
L
, ValidLogEnable<L> = 0>
voidlog
(const std::string &message)¶ Logs the message, which should already be formatted.
- Note
This overload is only enabled if the level L is less than or equal to the level of the logger.
- Parameters
message
: The message to log.
- Template Parameters
L
: The log level for the message.
Public Static Functions