Previously, text_file_backend would generate a new file name when the file
name pattern contained a file counter placeholder, which prevented appending
to the file. Appending was only possible when the active file name was
stable across process restarts (effectively, this prohibited the file counter
to be used in the active file name).
This commit adds support for appending in such configuration. The file
collector has been updated to return the last found file counter during
filesystem scanning, and the sink backend doesn't increment it when the initial
file is opened, when appending is enabled, and when the file to be opened
exists and, if file collector is used, is in the target storage of the file
collector. In all other cases the file counter is incremented, which leaves
the behavior unchanged.
Closes https://github.com/boostorg/log/issues/179.
Text ostream, file and multifile sink backends now support controlling trailing
newline insertion after every log records. The supported modes are described by
the auto_newline_mode enum. The behavior can be controlled via the same-named
named parameter, a set_auto_newline_mode call or the AutoNewline parameter
in the settings.
The default behavior has changed from the previous releases. From now on the
trailing newline will only be added if there isn't one in the formatted log
message already.
This allows to have different file names when actively writing the log file
and when rotating. In particular, this solves the problem with appending
to the previous file, when the log files are also collected and are supposed
to have distincs names.
This can be useful when the final rotation cannot be performed while global destructors are run (e.g. when a close handler depends on a global state).
It can also be useful to implement file appending with collector set up to a different target directory than the directory the backend writes to.