matador::rotating_file_sink Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ rotating_file_sink()

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.

Parameters
pathPath of the log file
max_sizeMax log file size
file_countMax log file count

Member Function Documentation

◆ close()

void matador::rotating_file_sink::close ( )
overridevirtual

Close all open log files

Implements matador::log_sink.

◆ write()

void matador::rotating_file_sink::write ( const char *  message,
size_t  size 
)
override

Write the message to current log file. If the actual size exceeds the file size limit the log files are rotated.

Parameters
messageLog message to write
sizeThe size of the log message

The documentation for this class was generated from the following file:
  • matador/logger/rotating_file_sink.hpp