A class for logging messages to the console and to files.
More...
#include <logger.hpp>
|
| | Logger () |
| | Construct a new Logger object. More...
|
| |
| | Logger (const std::filesystem::path &path) |
| | Construct a new Logger object and open 5 different files for logging. If the files exist, they will be overwritten. More...
|
| |
| void | configure (const std::filesystem::path &path) |
| | Open 5 different files for logging. If the files exist, they will be overwritten. More...
|
| |
| void | setLevel (Level level) |
| | Set the minimum level of messages to log to the console. More...
|
| |
| Level | level () const |
| | Return the minimum level of messages to log to the console. More...
|
| |
| void | setTimestamp (bool enabled) |
| | Enable or disable timestamps. More...
|
| |
| Logger & | operator<< (Level level) |
| | Set the message level. More...
|
| |
| Logger & | operator<< (std::ostream &(*manipulator)(std::ostream &)) |
| | Transfer a manipulator to the stringstream buffer waiting to be flushed. If the manipulator is std::endl, the buffer will be flushed. More...
|
| |
| template<typename T > |
| Logger & | operator<< (T const &arg) |
| | Transfer a argument to the stringstream buffer waiting to be flushed. More...
|
| |
A class for logging messages to the console and to files.
◆ Level
The different levels of logging.
| Enumerator |
|---|
| CRITICAL | |
| ERROR | |
| WARNING | |
| INFO | |
| DEBUG | |
| TRACE | |
| MAX | |
◆ Logger() [1/2]
Construct a new Logger object.
◆ Logger() [2/2]
| Logger::Logger |
( |
const std::filesystem::path & |
path | ) |
|
Construct a new Logger object and open 5 different files for logging. If the files exist, they will be overwritten.
- Parameters
-
| path | The path to the log files. |
- Exceptions
-
| std::runtime_error | if a log file could not be opened. |
◆ configure()
| void Logger::configure |
( |
const std::filesystem::path & |
path | ) |
|
Open 5 different files for logging. If the files exist, they will be overwritten.
- Parameters
-
| path | The path to the log files. |
- Exceptions
-
| std::runtime_error | if a log file could not be opened. |
◆ level()
Return the minimum level of messages to log to the console.
◆ operator<<() [1/3]
Set the message level.
- Parameters
-
- Exceptions
-
| std::runtime_error | if a message is currently being logged. |
◆ operator<<() [2/3]
| Logger & Logger::operator<< |
( |
std::ostream &(*)(std::ostream &) |
manipulator | ) |
|
Transfer a manipulator to the stringstream buffer waiting to be flushed. If the manipulator is std::endl, the buffer will be flushed.
- Parameters
-
| manipulator | The manipulator to transfer. |
◆ operator<<() [3/3]
template<typename T >
| Logger & Logger::operator<< |
( |
T const & |
arg | ) |
|
|
inline |
Transfer a argument to the stringstream buffer waiting to be flushed.
- Parameters
-
| arg | The argument to transfer. |
◆ setLevel()
| void Logger::setLevel |
( |
Level |
level | ) |
|
Set the minimum level of messages to log to the console.
- Parameters
-
◆ setTimestamp()
| void Logger::setTimestamp |
( |
bool |
enabled | ) |
|
Enable or disable timestamps.
- Parameters
-
| enabled | Whether or not to enable timestamps. |
The documentation for this class was generated from the following files: