#include <ImFusion/Core/Log/FileSink.h>
Default implementation for a Logger that writes to the filesystem.
More...
Default implementation for a Logger that writes to the filesystem.
|
| FileSink (const Filesystem::Path &filename, Flags< Options > options=Options::None) |
| Instantiates a new FileLogger.
|
|
Result | rotateFiles (ByteSize sizeLimit, int numArchived) |
| Performs log file rotation for this sink if applicable.
|
|
const Filesystem::Path & | filename () const |
| Returns the path of the log file.
|
|
std::vector< Filesystem::Path > | filenames () const |
| Returns the path of the log file as well as a best-effort list of archived log files.
|
|
void | log (const LogCapture &capture) |
| Logs the given message.
|
|
bool | isAccepted (Level level, const char *category) noexcept |
| Checks whether a log message of given level and category is accepted (i.e.
|
|
void | addWhitelistFilter (Log::Level minLevel, const std::string &category) |
| Adds a whitelist filter for this logger: both conditions of the filter must be met to accept a message.
|
|
void | addBlacklistFilter (Log::Level maxLevel, const std::string &category) |
| Adds a blacklist filter for this logger: both conditions of the filter must be met to reject a message.
|
|
const std::vector< Filter > & | whitelistFilters () const |
| Return the set of whitelist filters.
|
|
const std::vector< Filter > & | blacklistFilters () const |
| Return the set of blacklist filters.
|
|
void | removeFilters (const std::string &category) |
| Removes all filters matching category .
|
|
void | clearFilters () |
| Clear all filters.
|
|
bool | isEnabled () const |
| Returns the flag whether this logger is enabled.
|
|
void | setEnabled (bool value) |
| Sets the flag whether this logger is enabled.
|
|
|
void | logImpl (const LogCapture &capture) override |
| Performs the actual logging of the given message.
|
|
void | flush () override |
| Ensure that all log captures are fully committed/written.
|
|
void | openLogfile (Flags< Options > options) |
|
void | closeLogfile () |
|
◆ Options
Configuration options.
Enumerator |
---|
None | Append log output to the log file.
|
Truncate | Clear the log file.
|
SequentialThreadIds | Use sequential thread IDs starting from 0 instead of the ones from the OS.
|
◆ Result
Enumeration of possible return values of rotateFiles()
Enumerator |
---|
NoActionNeeded | No log file rotation was performed since the log file size was lower than the threshold.
|
Successful | Log file rotation succeeded.
|
Failed | Log file rotation failed and was aborted.
|
◆ FileSink()
Instantiates a new FileLogger.
- Parameters
-
filename | File name for the log file. |
options | Configuration options. |
- Exceptions
-
◆ rotateFiles()
Performs log file rotation for this sink if applicable.
If the current log file size exceeds sizeLimit
a log file rotation will be performed keeping up to numArchived
archived files around in addition to the active log file. If the total number of archived log files exceeds this threshold the oldest archived log file will be deleted.
Archived files will be named <logfile-basename>_N.<logfile-extension>
where N
is counted from 1
to numArchived
.
- Warning
- This function is not thread-safe. Do not call it while another thread might write to this sink as it might lose or corrupt the log file. It is safest if you call this function directly after construction and before calling Log::addSink().
◆ logImpl()
Performs the actual logging of the given message.
Called by log() after filtering.
- Parameters
-
Implements Sink.
◆ flush()
Ensure that all log captures are fully committed/written.
Implements Sink.
The documentation for this class was generated from the following file:
- ImFusion/Core/Log/FileSink.h