VoidLoader/VoidLoaderCore/pipeline/head There was a failure building this commit
Signed-off-by: Faumaray <faumaray@gmail.com>
34 lines
863 B
C++
34 lines
863 B
C++
#pragma once
|
|
#include <Logging/Sink.hpp>
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
namespace vl::logging {
|
|
|
|
// File rotation: R3 (daily + index), plus optional size cap
|
|
class FileSink final : public Sink {
|
|
public:
|
|
explicit FileSink(std::string basePath, std::uintmax_t maxBytes);
|
|
|
|
void write(const Message& msg) override;
|
|
|
|
private:
|
|
std::string base_;
|
|
std::uintmax_t maxBytes_;
|
|
std::ofstream out_;
|
|
std::string currentDate_; // YYYY-MM-DD
|
|
int index_{1};
|
|
std::uintmax_t written_{0};
|
|
|
|
void ensureOpen(const Message& msg);
|
|
void openCurrent();
|
|
void rotateToDate(std::string newDate);
|
|
|
|
static std::string dateOf(const std::chrono::system_clock::time_point& tp);
|
|
static std::string filenameFor(const std::string& base, std::string_view date, int index);
|
|
};
|
|
|
|
} // namespace vl::log
|