|
|
@ -22,22 +22,19 @@ namespace sinks {
|
|
|
|
template <typename Mutex>
|
|
|
|
template <typename Mutex>
|
|
|
|
class rotating_file_sink final : public base_sink<Mutex> {
|
|
|
|
class rotating_file_sink final : public base_sink<Mutex> {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
// @param rotation_file_format: the file format for rotation files.
|
|
|
|
|
|
|
|
// NOTE: If [index] is 0, [filename] is expected to return.
|
|
|
|
rotating_file_sink(filename_t base_filename,
|
|
|
|
rotating_file_sink(filename_t base_filename,
|
|
|
|
std::size_t max_size,
|
|
|
|
std::size_t max_size,
|
|
|
|
std::size_t max_files,
|
|
|
|
std::size_t max_files,
|
|
|
|
bool rotate_on_open = false,
|
|
|
|
bool rotate_on_open = false,
|
|
|
|
const file_event_handlers &event_handlers = {});
|
|
|
|
const file_event_handlers &event_handlers = {},
|
|
|
|
|
|
|
|
std::function<filename_t(const filename_t &filename, std::size_t index)> rotation_file_format = {});
|
|
|
|
// Default function to get rotation filename by base filename and rotation file index.
|
|
|
|
// Default function to get rotation filename by base filename and rotation file index.
|
|
|
|
static filename_t calc_filename(const filename_t &filename, std::size_t index);
|
|
|
|
static filename_t calc_filename(const filename_t &filename, std::size_t index);
|
|
|
|
filename_t filename();
|
|
|
|
filename_t filename();
|
|
|
|
void rotate_now();
|
|
|
|
void rotate_now();
|
|
|
|
|
|
|
|
|
|
|
|
// Set the file format for rotation files.
|
|
|
|
|
|
|
|
// NOTE:
|
|
|
|
|
|
|
|
// 1. The format function is supposed to be called only once, otherwise check failure.
|
|
|
|
|
|
|
|
// 2. If [index] is 0, [filename] is expected to return.
|
|
|
|
|
|
|
|
void set_rotate_filename_format(std::function<filename_t(const filename_t &filename, std::size_t index)> rotation_file_format);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
void sink_it_(const details::log_msg &msg) override;
|
|
|
|
void sink_it_(const details::log_msg &msg) override;
|
|
|
|
void flush_() override;
|
|
|
|
void flush_() override;
|
|
|
|