81 std::string* error =
nullptr);
83 void write(
LogLevel level, std::string_view category, std::string_view message)
const;
93 std::filesystem::path
path()
const;
104 explicit FileLogSink(std::shared_ptr<Impl> impl) : impl_(
std::move(impl)) {}
105 std::shared_ptr<Impl> impl_;
121 void write(
LogLevel level, std::string_view category, std::string_view message)
const;
145 std::shared_ptr<Impl> impl_;
std::vector< LogRecord > records_at_least(LogLevel min_level) const
Snapshot of records at or above min_level.
std::uint64_t dropped_count() const
Records discarded because the list was full.
bool contains(std::string_view needle) const
True if any retained message contains needle.
std::vector< LogRecord > take()
Return the records and empty the list.
std::vector< LogRecord > records() const
Snapshot, oldest first.
CaptureLogSink(std::size_t max_records=4096)
void write(LogLevel level, std::string_view category, std::string_view message) const
LogSink sink() const
The sink function for set_log_sink.
std::uint64_t dropped_count() const
Records that could not be written.
void write(LogLevel level, std::string_view category, std::string_view message) const
static std::optional< FileLogSink > open(FileLogSinkOptions options, std::string *error=nullptr)
Open (creating if needed) the log.
std::filesystem::path rotated_path(int index) const
Path of rotated copy index (1 is the newest).
const std::filesystem::path & directory() const
Resolved directory and live file path.
std::filesystem::path path() const
ScopedLogSink & operator=(const ScopedLogSink &)=delete
ScopedLogSink(const ScopedLogSink &)=delete
~ScopedLogSink()
Definition log_sink.hpp:154
ScopedLogSink(LogSink sink)
Definition log_sink.hpp:153
Definition generated_event_source.hpp:33
LogLevel
Definition log.hpp:42
@ Info
Definition log.hpp:42
std::function< void(LogLevel level, std::string_view category, std::string_view message)> LogSink
Receives every record after the platform writers.
Definition log.hpp:49
LogSink set_log_sink(LogSink sink)
Install sink as the process-wide log sink and return the previous one (empty if none).
Definition log.hpp:147
Definition log_sink.hpp:29
std::uint64_t max_file_bytes
A record that would grow the file past this rotates it first.
Definition log_sink.hpp:43
int max_files
Live file plus rotated copies kept (pulp.log, pulp.log.1, ..., newest rotation first).
Definition log_sink.hpp:48
LogLevel min_level
Records below this level are not written.
Definition log_sink.hpp:51
std::filesystem::path directory
Directory that holds the log.
Definition log_sink.hpp:33
std::string app_name
Names the subdirectory under the platform log directory when directory is empty.
Definition log_sink.hpp:37
std::string file_name
Log file name inside the directory. A single path component.
Definition log_sink.hpp:40
Definition log_sink.hpp:108
std::string message
Definition log_sink.hpp:111
LogLevel level
Definition log_sink.hpp:109
std::string category
Definition log_sink.hpp:110