Skip to main content

Syslog

Struct Syslog 

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

Encodes LogEvents in RFC 5424 syslog format.

The hostname and app-name fields in the syslog header are configurable at construction time. They default to "sonda" and "sonda" respectively.

Only encode_log is supported. encode_metric returns an error because syslog is a log-only format.

Implementations§

Source§

impl Syslog

Source

pub fn new(hostname: Option<String>, app_name: Option<String>) -> Self

Create a new Syslog encoder with the given hostname and app-name.

§Arguments
  • hostname — The HOSTNAME field. Defaults to "sonda" if None.
  • app_name — The APP-NAME field. Defaults to "sonda" if None.

Trait Implementations§

Source§

impl Default for Syslog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Encoder for Syslog

Source§

fn encode_metric( &self, _event: &MetricEvent, _buf: &mut Vec<u8>, ) -> Result<(), SondaError>

Syslog encodes only log events. Returns an error for metric events.

Source§

fn encode_log( &self, event: &LogEvent, buf: &mut Vec<u8>, ) -> Result<(), SondaError>

Encode a log event as an RFC 5424 syslog line appended to buf.

Format (no labels): <priority>1 timestamp hostname app-name - - - message\n Format (with labels): <priority>1 timestamp hostname app-name - - [sonda k="v" ...] message\n

Priority = (facility * 8) + syslog_severity. Facility 1 (user-level) is used.

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, 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.