9 #ifndef CPPLOGGING_APPENDERS_ROLLING_FILE_APPENDER_H
10 #define CPPLOGGING_APPENDERS_ROLLING_FILE_APPENDER_H
14 #include "filesystem/filesystem.h"
37 template <
class TOutputStream>
110 explicit 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);
119 bool IsStarted() const noexcept override;
120 bool Start() override;
121 bool Stop() override;
123 void Flush() override;
140 Impl& impl() noexcept {
return reinterpret_cast<Impl&
>(_storage); }
141 const Impl& impl() const noexcept {
return reinterpret_cast<Impl const&
>(_storage); }
143 static const size_t StorageSize = 608;
144 static const size_t StorageAlign = 8;
145 alignas(StorageAlign) std::byte _storage[StorageSize];
Logging appender interface definition.
Logging appender interface.
virtual void onArchiveThreadInitialize()
Initialize archivation thread handler.
friend class SizePolicyImpl
void AppendRecord(Record &record) override
Append the given logging record.
bool IsStarted() const noexcept override
Is the logging element started?
bool Start() override
Start the logging element.
friend class TimePolicyImpl
RollingFileAppender & operator=(RollingFileAppender &&appender)=delete
bool Stop() override
Stop the logging element.
virtual ~RollingFileAppender()
RollingFileAppender(const RollingFileAppender &)=delete
void Flush() override
Flush the logging appender.
RollingFileAppender & operator=(const RollingFileAppender &)=delete
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.
virtual void onArchiveThreadCleanup()
Cleanup archivation thread handler.
RollingFileAppender(RollingFileAppender &&appender)=delete
C++ Logging project definitions.
TimeRollingPolicy
Time rolling policy.
@ SECOND
Second rolling policy.
@ MONTH
Monthly rolling policy.
@ MINUTE
Minute rolling policy.
@ DAY
Daily rolling policy.
@ YEAR
Year rolling policy.
@ HOUR
Hour rolling policy.
TOutputStream & operator<<(TOutputStream &stream, TimeRollingPolicy policy)
Stream output: Time rolling policy.
Rolling file appender inline implementation.