14 : _file(file), _truncate(truncate), _auto_flush(auto_flush)
51 if (record.
raw.empty())
59 _file.Write(record.
raw.data(), record.
raw.size() - 1);
65 catch (
const CppCommon::FileSystemException&)
82 catch (
const CppCommon::FileSystemException&)
90 bool FileAppender::PrepareFile()
95 if (_file.IsFileWriteOpened())
99 if ((CppCommon::Timestamp::utc() - _retry).milliseconds() < 100)
103 if (_file.IsFileReadOpened())
107 _file.OpenOrCreate(
false,
true, _truncate);
114 catch (
const CppCommon::FileSystemException&)
117 _retry = CppCommon::Timestamp::utc();
122 bool FileAppender::CloseFile()
130 catch (
const CppCommon::FileSystemException&) {
return false; }
bool IsStarted() const noexcept override
Is the logging element started?
bool Start() override
Start the logging element.
void AppendRecord(Record &record) override
Append the given logging record.
void Flush() override
Flush the logging appender.
bool Stop() override
Stop the logging element.
FileAppender(const CppCommon::Path &file, bool truncate=false, bool auto_flush=false, bool auto_start=true)
Initialize the appender with a given file, truncate/append and auto-flush flags.
std::vector< uint8_t > raw
Record content after layout.
File appender definition.
C++ Logging project definitions.