Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::runtime::FileLogSink Class Reference

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.

Detailed Description

Appends records to a rotating file.

Safety: open refuses a target it cannot trust, and reports why.

  • The log directory must be a real directory (not a symlink), owned by the current user, and not writable by group or others.
  • The log file is opened without following links, must be a regular file owned by the current user with a single hard link, and must not be writable by group or others. Files are created 0600 and tightened to 0600 if they were more permissive.
  • On POSIX the directory is held open and every file operation is relative to it, so replacing the directory with a link after open has no effect.

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.

Member Function Documentation

◆ directory()

const std::filesystem::path & pulp::runtime::FileLogSink::directory ( ) const

Resolved directory and live file path.

◆ dropped_count()

std::uint64_t pulp::runtime::FileLogSink::dropped_count ( ) const

Records that could not be written.

◆ open()

std::optional< FileLogSink > pulp::runtime::FileLogSink::open ( FileLogSinkOptions options,
std::string * error = nullptr )
static

Open (creating if needed) the log.

Returns nullopt and fills error when the location cannot be trusted or created.

◆ operator LogSink()

pulp::runtime::FileLogSink::operator LogSink ( ) const
inline

◆ path()

std::filesystem::path pulp::runtime::FileLogSink::path ( ) const

◆ rotated_path()

std::filesystem::path pulp::runtime::FileLogSink::rotated_path ( int index) const

Path of rotated copy index (1 is the newest).

◆ sink()

LogSink pulp::runtime::FileLogSink::sink ( ) const

The sink function for set_log_sink.

◆ write()

void pulp::runtime::FileLogSink::write ( LogLevel level,
std::string_view category,
std::string_view message ) const

The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/runtime/include/pulp/runtime/log_sink.hpp