quill
Public Types | Public Member Functions | List of all members
RotatingFileSinkConfig Class Reference

The configuration options for the RotatingSink. More...

#include <RotatingSink.h>

Inheritance diagram for RotatingFileSinkConfig:
Inheritance graph
[legend]
Collaboration diagram for RotatingFileSinkConfig:
Collaboration graph
[legend]

Public Types

enum  RotationFrequency : uint8_t { Disabled, Daily, Hourly, Minutely }
 The frequency of log file rotation.
 
enum  RotationNamingScheme : uint8_t { Index, Date, DateAndTime }
 The naming scheme for rotated log files.
 

Public Member Functions

 RotatingFileSinkConfig ()
 Constructs a new RotatingFileSinkConfig object.
 
QUILL_ATTRIBUTE_COLD void set_rotation_max_file_size (size_t value)
 Sets the maximum file size for rotation. More...
 
QUILL_ATTRIBUTE_COLD void set_rotation_frequency_and_interval (char frequency, uint32_t interval)
 Sets the frequency and interval of file rotation. More...
 
QUILL_ATTRIBUTE_COLD void set_rotation_time_daily (std::string const &daily_rotation_time_str)
 Sets the time of day for daily log file rotation. More...
 
QUILL_ATTRIBUTE_COLD void set_max_backup_files (uint32_t value)
 Sets the maximum number of log files to keep. More...
 
QUILL_ATTRIBUTE_COLD void set_overwrite_rolled_files (bool value)
 Sets whether the oldest rolled logs should be overwritten when the maximum backup count is reached. More...
 
QUILL_ATTRIBUTE_COLD void set_remove_old_files (bool value)
 Sets whether previous rotated log files should be removed on process start up. More...
 
QUILL_ATTRIBUTE_COLD void set_rotation_naming_scheme (RotationNamingScheme value)
 Sets the naming scheme for the rotated files. More...
 
QUILL_ATTRIBUTE_COLD void set_rotation_on_creation (bool value)
 Sets whether to force rotation on file sink creation/startup. More...
 
QUILL_NODISCARD size_t rotation_max_file_size () const noexcept
 Getter methods.
 
QUILL_NODISCARD uint32_t max_backup_files () const noexcept
 
QUILL_NODISCARD bool overwrite_rolled_files () const noexcept
 
QUILL_NODISCARD bool remove_old_files () const noexcept
 
QUILL_NODISCARD RotationFrequency rotation_frequency () const noexcept
 
QUILL_NODISCARD uint32_t rotation_interval () const noexcept
 
QUILL_NODISCARD std::pair< std::chrono::hours, std::chrono::minutes > daily_rotation_time () const noexcept
 
QUILL_NODISCARD RotationNamingScheme rotation_naming_scheme () const noexcept
 
QUILL_NODISCARD bool rotation_on_creation () const noexcept
 
- Public Member Functions inherited from FileSinkConfig
QUILL_ATTRIBUTE_COLD void set_filename_append_option (FilenameAppendOption value, std::string_view append_filename_format_pattern=std::string_view{})
 Sets the append type for the file name. More...
 
QUILL_ATTRIBUTE_COLD void set_timezone (Timezone time_zone)
 Sets the timezone to use for time-based operations e.g. More...
 
QUILL_ATTRIBUTE_COLD void set_fsync_enabled (bool value)
 Sets whether fsync should be performed when flushing. More...
 
QUILL_ATTRIBUTE_COLD void set_open_mode (char open_mode)
 Sets the open mode for the file. More...
 
QUILL_ATTRIBUTE_COLD void set_open_mode (std::string_view open_mode)
 Sets the open mode for the file. More...
 
QUILL_ATTRIBUTE_COLD void set_write_buffer_size (size_t value)
 Sets the user-defined buffer size for fwrite operations. More...
 
QUILL_ATTRIBUTE_COLD void set_minimum_fsync_interval (std::chrono::milliseconds value)
 Sets the minimum interval between fsync calls. More...
 
QUILL_ATTRIBUTE_COLD void set_override_pattern_formatter_options (std::optional< PatternFormatterOptions > const &options)
 Sets custom pattern formatter options for this sink. More...
 
QUILL_NODISCARD bool fsync_enabled () const noexcept
 Getters.
 
QUILL_NODISCARD Timezone timezone () const noexcept
 
QUILL_NODISCARD FilenameAppendOption filename_append_option () const noexcept
 
QUILL_NODISCARD std::string const & append_filename_format_pattern () const noexcept
 
QUILL_NODISCARD std::string const & open_mode () const noexcept
 
QUILL_NODISCARD size_t write_buffer_size () const noexcept
 
QUILL_NODISCARD std::chrono::milliseconds minimum_fsync_interval () const noexcept
 
QUILL_NODISCARD std::optional< PatternFormatterOptions > const & override_pattern_formatter_options () const noexcept
 

Detailed Description

The configuration options for the RotatingSink.

Member Function Documentation

◆ set_max_backup_files()

QUILL_ATTRIBUTE_COLD void RotatingFileSinkConfig::set_max_backup_files ( uint32_t  value)
inline

Sets the maximum number of log files to keep.

Parameters
valueThe maximum number of log files

◆ set_overwrite_rolled_files()

QUILL_ATTRIBUTE_COLD void RotatingFileSinkConfig::set_overwrite_rolled_files ( bool  value)
inline

Sets whether the oldest rolled logs should be overwritten when the maximum backup count is reached.

If set to false, the oldest logs will not be overwritten when the maximum backup count is reached, and log file rotation will stop. The default value is true.

Parameters
valueTrue to overwrite the oldest logs, false otherwise.

◆ set_remove_old_files()

QUILL_ATTRIBUTE_COLD void RotatingFileSinkConfig::set_remove_old_files ( bool  value)
inline

Sets whether previous rotated log files should be removed on process start up.

Note
This option works only when using the mode="w" This is useful to avoid conflicting file names when the process restarts and FilenameAppend::DateTime was not set. The default value is true.
Parameters
valueTrue to remove old log files, false otherwise.

◆ set_rotation_frequency_and_interval()

QUILL_ATTRIBUTE_COLD void RotatingFileSinkConfig::set_rotation_frequency_and_interval ( char  frequency,
uint32_t  interval 
)
inline

Sets the frequency and interval of file rotation.

Parameters
frequencyThe frequency of file rotation ('M' for minutes, 'H' for hours)
intervalThe rotation interval

◆ set_rotation_max_file_size()

QUILL_ATTRIBUTE_COLD void RotatingFileSinkConfig::set_rotation_max_file_size ( size_t  value)
inline

Sets the maximum file size for rotation.

Parameters
valueThe maximum file size in bytes per file

◆ set_rotation_naming_scheme()

QUILL_ATTRIBUTE_COLD void RotatingFileSinkConfig::set_rotation_naming_scheme ( RotationNamingScheme  value)
inline

Sets the naming scheme for the rotated files.

The default value is 'Index'.

Parameters
valueThe naming scheme to set.

◆ set_rotation_on_creation()

QUILL_ATTRIBUTE_COLD void RotatingFileSinkConfig::set_rotation_on_creation ( bool  value)
inline

Sets whether to force rotation on file sink creation/startup.

When enabled, if a log file with the same name exists on startup, it will be rotated according to the RotationNamingScheme before starting to write new logs. This allows creating a new log file for every program run. The default value is false.

Parameters
valueTrue to force rotation on creation, false otherwise.

◆ set_rotation_time_daily()

QUILL_ATTRIBUTE_COLD void RotatingFileSinkConfig::set_rotation_time_daily ( std::string const &  daily_rotation_time_str)
inline

Sets the time of day for daily log file rotation.

Parameters
daily_rotation_time_strThe time of day for rotation (format: "HH:MM")

The documentation for this class was generated from the following file: