CppLogging
1.0.4.0
C++ Logging Library
|
Rolling file appender. More...
#include <rolling_file_appender.h>
Public Member Functions | |
RollingFileAppender (const CppCommon::Path &path, TimeRollingPolicy policy=TimeRollingPolicy::DAY, const std::string &pattern="{UtcDateTime}.log", bool archive=false, bool truncate=false, bool auto_flush=false, bool auto_start=true) | |
Initialize the rolling file appender with a time-based policy. More... | |
RollingFileAppender (const CppCommon::Path &path, const std::string &filename, const std::string &extension, size_t size=104857600, size_t backups=10, bool archive=false, bool truncate=false, bool auto_flush=false, bool auto_start=true) | |
Initialize the rolling file appender with a size-based policy. More... | |
RollingFileAppender (const RollingFileAppender &)=delete | |
RollingFileAppender (RollingFileAppender &&appender)=delete | |
virtual | ~RollingFileAppender () |
RollingFileAppender & | operator= (const RollingFileAppender &)=delete |
RollingFileAppender & | operator= (RollingFileAppender &&appender)=delete |
bool | IsStarted () const noexcept override |
Is the logging element started? More... | |
bool | Start () override |
Start the logging element. More... | |
bool | Stop () override |
Stop the logging element. More... | |
void | AppendRecord (Record &record) override |
Append the given logging record. More... | |
void | Flush () override |
Flush the logging appender. More... | |
Protected Member Functions | |
virtual void | onArchiveThreadInitialize () |
Initialize archivation thread handler. More... | |
virtual void | onArchiveThreadCleanup () |
Cleanup archivation thread handler. More... | |
Friends | |
class | SizePolicyImpl |
class | TimePolicyImpl |
Rolling file appender.
Rolling file appender writes the given logging record into the file and performs file rolling operation depends on the given policy. In case of any IO error this appender will lost the logging record, but try to recover from fail in a short interval of 100ms.
Time-based rolling policy will create a new logging file to write into using a special pattern (contains date & time placeholders).
Size-based rolling policy will create a new logging file to write when the current file size exceeded size limit. Logging backups are indexed and its count could be limited as well.
It is possible to enable archivation of the logging backups in a background thread.
Not thread-safe.
Definition at line 59 of file rolling_file_appender.h.
|
explicit |
Initialize the rolling file appender with a time-based policy.
Time-based policy composes logging filename from the given pattern using the following placeholders:
path | - Logging path |
policy | - Time-based rolling policy (default is TimeRollingPolicy::DAY) |
pattern | - Logging pattern (default is "{UtcDateTime}.log") |
archive | - Archivation flag (default is false) |
truncate | - Truncate flag (default is false) |
auto_flush | - Auto-flush flag (default is false) |
auto_start | - Auto-start flag (default is true) |
Definition at line 1176 of file rolling_file_appender.cpp.
|
explicit |
Initialize the rolling file appender with a size-based policy.
Size-based policy for 5 backups works in a following way:
example.log -> example.1.log example.1.log -> example.2.log example.2.log -> example.3.log example.3.log -> example.4.log example.4.log -> example.5.log example.5.log -> remove
path | - Logging path |
filename | - Logging filename |
extension | - Logging extension |
size | - Rolling size limit in bytes (default is 100 megabytes) |
backups | - Rolling backups count (default is 10) |
archive | - Archivation flag (default is false) |
truncate | - Truncate flag (default is false) |
auto_flush | - Auto-flush flag (default is false) |
auto_start | - Auto-start flag (default is true) |
Definition at line 1187 of file rolling_file_appender.cpp.
|
delete |
|
delete |
|
virtual |
Definition at line 1198 of file rolling_file_appender.cpp.
|
overridevirtual |
Append the given logging record.
record | - Logging record |
Implements CppLogging::Appender.
Definition at line 1207 of file rolling_file_appender.cpp.
|
overridevirtual |
Flush the logging appender.
Reimplemented from CppLogging::Appender.
Definition at line 1208 of file rolling_file_appender.cpp.
|
overridevirtualnoexcept |
Is the logging element started?
Reimplemented from CppLogging::Element.
Definition at line 1204 of file rolling_file_appender.cpp.
|
inlineprotectedvirtual |
Cleanup archivation thread handler.
This handler can be used to cleanup priority or affinity of the archivation thread.
Definition at line 135 of file rolling_file_appender.h.
|
inlineprotectedvirtual |
Initialize archivation thread handler.
This handler can be used to initialize priority or affinity of the archivation thread.
Definition at line 130 of file rolling_file_appender.h.
|
delete |
|
delete |
|
overridevirtual |
Start the logging element.
Reimplemented from CppLogging::Element.
Definition at line 1205 of file rolling_file_appender.cpp.
|
overridevirtual |
Stop the logging element.
Reimplemented from CppLogging::Element.
Definition at line 1206 of file rolling_file_appender.cpp.
|
friend |
Definition at line 61 of file rolling_file_appender.h.
|
friend |
Definition at line 62 of file rolling_file_appender.h.