Struct AsyncSyslog

Source
pub struct AsyncSyslog<D = SyslogLocal, F = DefaultSyslogFormatter, IO = DefaultIOs, MUX = DefaultAsyncMutex<F, D, IO>>(/* private fields */)
where
    D: AsyncSyslogDestination,
    F: SyslogFormatter + Sync,
    MUX: AsyncMutex<F, D, AsyncSyslogInternal<F, D, IO>>,
    IO: AsyncSyslogInternalIO;
Expand description

A main instance of the Syslog client.

  • D - a SyslogDestination instance which is either: SyslogLocal, SyslogFile, [SyslogNet], SyslogTls or other. By default a SyslogLocal is selected.

  • ‘F’ - a SyslogFormatter formatter which should format the message for the SyslogDestination (D). By deafult, the DefaultSyslogFormatter is used which automatically selects the formatter which is used by syslog on the current system. If current crate does not have a build-in formatter, then a new one should be created.

  • ‘IO’ - a AsyncSyslogInternalIO an additional IO like writing to syscons or stderr. And thread operations like sleep. By default a DefaultIOs is used which automatically picks correct instance.

  • ’MUX` - a AsyncMutex implementation above the mutex instance. By default, a DefaultAsyncMutex is used which autoselects the correct mutex implementation.

Implementations§

Source§

impl AsyncSyslog

Source

pub async fn openlog( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap: SyslogLocal, ) -> SyRes<Self>

Opens a default async connection to the local syslog server with default formatter.

§Arguments
  • ident - A program name which will appear on the logs. If none, will be determined automatically.

  • logstat - LogStat an instance config.

  • facility - LogFacility a syslog facility.

  • net_tap -a SyslogLocal instance with configuration.

§Returns

A SyRes is returned (Result) with:

Source§

impl<F, D, IO, MUX> AsyncSyslog<D, F, IO, MUX>

A shared implementation.

Source

pub async fn openlog_with( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap: D, ) -> SyRes<AsyncSyslog<D, F, IO, MUX>>

Opens a special connection to the destination syslog server with specific formatter.

All struct generic should be specified before calling this function.

§Arguments
  • ident - A program name which will appear on the logs. If none, will be determined automatically.

  • logstat - LogStat an instance config.

  • facility - LogFacility a syslog facility.

  • net_tap - a destination server. A specific D instance which contains infomation about the destination server. See syslog_provider.rs.

§Returns

A SyRes is returned (Result) with:

Source

pub async fn setlogmask(&self, logmask: i32) -> i32

Sets the logmask to filter out the syslog calls. This function blocks until the previous mask is received.

See macroses [LOG_MASK] and [LOG_UPTO] to generate mask

§Example

LOG_MASK!(Priority::LOG_EMERG) | LOG_MASK!(Priority::LOG_ERROR)

or

~(LOG_MASK!(Priority::LOG_INFO)) LOG_UPTO!(Priority::LOG_ERROR)

Source

pub async fn change_identity(&self, ident: &str)

Changes the identity i.e program name which will appear on the logs.

Can return error if mutex is poisoned.

Source

pub async fn closelog(&self) -> SyRes<()>

Closes connection to the syslog server

Source

pub async fn syslog(&self, pri: Priority, fmt: String)

Similar to libc, syslog() sends data to syslog server.

§Arguments
  • pri - a priority Priority

  • fmt - a program’s message to be sent as payload.

Source

pub async fn vsyslog<M: AsRef<str>>(&self, pri: Priority, fmt: M)

Sends message to syslog (same as syslog).

Source

pub async fn reconnect(&self) -> SyRes<()>

Performs the reconnection to the syslog server or file re-open.

§Returns

A Result is retured as SyRes.

Source

pub async fn update_tap(&self, new_tap: D) -> SyRes<()>

Updates the inner instance destionation i.e path to file or server address. The type of destination can not be changed.

This function disconnects from syslog server if previously was connected (and reconnects if was connected previously).

§Arguments
§Returns

A SyRes is returned. An error may be returned if:

  • connection to server was failed

  • incorrect type

  • disconnect frm server failed

Trait Implementations§

Source§

impl<D, F, IO, MUX> Debug for AsyncSyslog<D, F, IO, MUX>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D, F, IO, MUX> Freeze for AsyncSyslog<D, F, IO, MUX>
where MUX: Freeze,

§

impl<D, F, IO, MUX> RefUnwindSafe for AsyncSyslog<D, F, IO, MUX>

§

impl<D, F, IO, MUX> Send for AsyncSyslog<D, F, IO, MUX>
where MUX: Send,

§

impl<D, F, IO, MUX> Sync for AsyncSyslog<D, F, IO, MUX>
where MUX: Sync, D: Sync, IO: Sync,

§

impl<D, F, IO, MUX> Unpin for AsyncSyslog<D, F, IO, MUX>
where MUX: Unpin, D: Unpin, F: Unpin, IO: Unpin,

§

impl<D, F, IO, MUX> UnwindSafe for AsyncSyslog<D, F, IO, MUX>
where MUX: UnwindSafe, D: UnwindSafe, F: UnwindSafe, IO: UnwindSafe,

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.