Appends records to a rotating file. More...
#include <log_sink.hpp>
Public Member Functions | |
| void | write (LogLevel level, std::string_view category, std::string_view message) const |
| LogSink | sink () const |
| The sink function for set_log_sink. | |
| operator LogSink () const | |
| const std::filesystem::path & | directory () const |
| Resolved directory and live file path. | |
| std::filesystem::path | path () const |
| std::filesystem::path | rotated_path (int index) const |
| Path of rotated copy index (1 is the newest). | |
| std::uint64_t | dropped_count () const |
| Records that could not be written. | |
Static Public Member Functions | |
| static std::optional< FileLogSink > | open (FileLogSinkOptions options, std::string *error=nullptr) |
| Open (creating if needed) the log. | |
Appends records to a rotating file.
Safety: open refuses a target it cannot trust, and reports why.
Windows has no owner or mode bits to check: the sink refuses symlinks and junctions and relies on the inherited ACL of the per-user logs folder. Unavailable under WebAssembly, where open fails.
Records are written one per line: 2026-11-06T17:02:03.123Z [info] category: message. Line breaks and other control characters inside a record are escaped, so a message cannot forge a second record. Records longer than 8 KiB are truncated.
Thread-safe; writes are serialised. A failed write is counted and dropped.
| const std::filesystem::path & pulp::runtime::FileLogSink::directory | ( | ) | const |
Resolved directory and live file path.
| std::uint64_t pulp::runtime::FileLogSink::dropped_count | ( | ) | const |
Records that could not be written.
|
static |
Open (creating if needed) the log.
Returns nullopt and fills error when the location cannot be trusted or created.
|
inline |
| std::filesystem::path pulp::runtime::FileLogSink::path | ( | ) | const |
| std::filesystem::path pulp::runtime::FileLogSink::rotated_path | ( | int | index | ) | const |
Path of rotated copy index (1 is the newest).
| LogSink pulp::runtime::FileLogSink::sink | ( | ) | const |
The sink function for set_log_sink.
| void pulp::runtime::FileLogSink::write | ( | LogLevel | level, |
| std::string_view | category, | ||
| std::string_view | message ) const |