A rotating log file sink. More...
#include <rotating_file_sink.hpp>
Inherits matador::log_sink.
Public Member Functions | |
rotating_file_sink (const std::string &path, size_t max_size, size_t file_count) | |
void | write (const char *message, size_t size) override |
void | close () override |
Public Member Functions inherited from matador::log_sink | |
virtual | ~log_sink ()=default |
virtual void | write (const char *message, std::size_t size)=0 |
A rotating log file sink.
This log sink provides a possibility to rotate several log files if the current log file reaches the maximum size.
The user can define the maximum number of log files and the maximum size of the current log file
The name of the current log file is defined within the given logfile path. Each rotated (moved) log file gets an incremented number extension right before the file extension, e.g.:
Log file name is 'log.txt' the first rotated log file is named 'log-1.txt' and so on until the maximum number of log files is reached. Then it starts from the beginning. Keep in mind that the log file to which is currently written to is always named like the file name given within the path.
matador::rotating_file_sink::rotating_file_sink | ( | const std::string & | path, |
size_t | max_size, | ||
size_t | file_count | ||
) |
Creates a rotating log file sink within the given path with the given maximum number of rotating log files where each file size is never greater than the given max file size.
path | Path of the log file |
max_size | Max log file size |
file_count | Max log file count |
|
overridevirtual |
Close all open log files
Implements matador::log_sink.
|
override |
Write the message to current log file. If the actual size exceeds the file size limit the log files are rotated.
message | Log message to write |
size | The size of the log message |