quill
|
The FileSinkConfig class holds the configuration options for the FileSink. More...
#include <FileSink.h>
Public Member Functions | |
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_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 |
The FileSinkConfig class holds the configuration options for the FileSink.
|
inline |
Sets the append type for the file name.
Possible append types are: StartDate, StartDateTime or None. When this option is set, the file name will be appended with the start date or date and time timestamp of when the process started.
For example: application.log -> application_20230101.log (StartDate) application.log -> application_20230101_121020.log (StartDateTime)
value | The append type to set. Valid options are Date and DateAndTime. |
append_filename_format_pattern | Specifies a custom strftime format pattern to use for the filename. This parameter is only applicable when FilenameAppendOption::CustomDateTimeFormat is selected |
|
inline |
Sets whether fsync should be performed when flushing.
The default value is false.
value | True to perform fsync, false otherwise. |
|
inline |
Sets the minimum interval between fsync
calls.
This specifies the minimum time between consecutive fsync
operations but does not guarantee that fsync
will be called exactly at that interval.
For example, if some messages are flushed to the log and fsync
is skipped because it was previously called, and no further messages are written to the file, fsync
will not be called even if the minimum interval has passed. This is because the previous call was skipped due to the interval, and no new messages necessitate another fsync
call.
This feature is intended to mitigate concerns about frequent fsync
calls potentially causing disk wear.
Note: This option is only applicable when fsync
is enabled. By default, the value is 0, which means that fsync
will be called periodically by the backend worker thread when messages are written to the file, irrespective of the interval.
value | The minimum interval, in milliseconds, between fsync calls. |
|
inline |
Sets the open mode for the file.
Valid options for the open mode are 'a' or 'w'. The default value is 'a'.
open_mode | open mode for the file. |
|
inline |
Sets custom pattern formatter options for this sink.
By default, the logger's pattern formatter is used to format log messages. This function allows overriding the default formatter with custom options for this specific sink. If a custom formatter is provided, it will be used instead of the logger's formatter.
options | The custom pattern formatter options to use |
|
inline |
Sets the timezone to use for time-based operations e.g.
when appending the date to the get_filename or when setting the logging pattern. Valid options for the timezone are 'LocalTime' or 'GmtTime' The default value is 'LocalTime'
time_zone | The timezone to use for time-based operations. |
|
inline |
Sets the user-defined buffer size for fwrite operations.
This function allows you to specify a custom buffer size for fwrite, improving efficiency for file write operations.
To disable custom buffering and revert to the default size, pass a value of 0.
value | Size of the buffer in bytes. If set to 0, the default buffer size will be used. |