Skip to main content

SyslogSink

Struct SyslogSink 

Source
pub struct SyslogSink { /* private fields */ }
Expand description

Forwards each event to the local syslog daemon via libc::syslog.

Unix-only (#[cfg(unix)]) — Windows has no syslog equivalent (Event Log / ETW are a different API surface). Windows callers should use FileSink and ship the file to whatever ingest the host runs.

Each call to emit invokes libc::syslog(priority, "%s", line) where priority is LOG_INFO | LOG_USER. The libc client takes care of socket-path portability (/dev/log on Linux, /var/run/syslog on macOS) and RFC3164/5424 framing — we don’t reimplement either.

§Process-singleton constraint

openlog(3) / closelog(3) mutate process-global state in the libc syslog client — a second openlog call replaces the first connection’s ident, and closelog tears down the connection for every holder. To avoid cross-close hazards, this type deliberately:

  1. Leaks the ident CString (Box::leak) so the pointer openlog retained stays valid for the process lifetime, and
  2. Does not implement Drop (no closelog call).

Construct at most one SyslogSink per process. The CLI does exactly this via resolve_audit_sink(). Library consumers that need a second syslog destination should wrap an existing Arc<SyslogSink> rather than calling SyslogSink::open again.

Implementations§

Source§

impl SyslogSink

Source

pub fn open(ident: &str) -> Result<Self>

Open a syslog connection with ident (program name shown in log entries). Default priority: LOG_INFO | LOG_USER.

Returns Err only if ident contains an interior NUL. The underlying openlog(3) is infallible — it does not perform I/O until the first syslog(3) call.

Trait Implementations§

Source§

impl AuditSink for SyslogSink

Available on Unix only.
Source§

fn emit(&self, event: &AuditEvent)

Source§

impl Debug for SyslogSink

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.