|
Avara3D 0.2.0
C++ API reference
|
LogSink that appends output to a file and rotates older files by size. More...
#include <a3d/log/sink/FileLogSink.h>
Public Member Functions | |
| FileLogSink (const std::filesystem::path &relPath, int maxFiles=DEFAULT_MAX_FILES, int maxFilesize=DEFAULT_MAX_FILESIZE) | |
| Creates an append-mode file sink with size-based rotation. More... | |
| const std::filesystem::path & | filepath () const |
| Returns the path of the active log file. More... | |
| int | maxFiles () const |
| Returns the configured maximum number of retained log files. More... | |
| int | maxFilesize () const |
| Returns the configured rotation size threshold in bytes. More... | |
| void | write (const std::string &output, Level level) override |
Appends output to the active file and performs size-based rotation when needed. More... | |
| void | flush () override |
| Flushes buffered output to the active file. More... | |
| virtual void | write (const std::string &output, Level level)=0 |
Writes already-formatted output associated with level. More... | |
| virtual void | flush () |
| Flushes buffered sink output; the base implementation does nothing. More... | |
LogSink that appends output to a file and rotates older files by size.
Rotation is checked after each write. Numbered backups are kept beside the active file and older backups are removed as the configured file limit is reached.
Definition at line 29 of file FileLogSink.h.
|
explicit |
Creates an append-mode file sink with size-based rotation.
Missing parent directories are created when possible. maxFilesize is measured in bytes; the defaults retain up to five files with a 1 MiB size threshold for each active file.
| std::invalid_argument | if maxFiles or maxFilesize is not greater than zero. |
| std::runtime_error | if required directories cannot be created or the log file cannot be opened. |
| const std::filesystem::path & a3d::log::FileLogSink::filepath | ( | ) | const |
Returns the path of the active log file.
|
overridevirtual |
Flushes buffered output to the active file.
Reimplemented from a3d::log::LogSink.
| int a3d::log::FileLogSink::maxFiles | ( | ) | const |
Returns the configured maximum number of retained log files.
| int a3d::log::FileLogSink::maxFilesize | ( | ) | const |
Returns the configured rotation size threshold in bytes.
|
overridevirtual |
Appends output to the active file and performs size-based rotation when needed.
Implements a3d::log::LogSink.