Struct SyslogQueue

Source
pub struct SyslogQueue<S, F = DefaultSyslogFormatter, D = SyslogLocal>{ /* private fields */ }
Expand description

An instance which is shared between all threads, but a MPSC channel is used to manage the simultanious action. A thread worker is receiving messages, formats and forwards to syslog serer (destination).

For this isntance a SyslogApi and StreamableSyslogApi are implemented.

Also if async is enabled, a [AsyncSyslogQueueApi] is implemented.

§Generics

Implementations§

Source§

impl<S: SyslogQueueChannel<DefaultSyslogFormatter, SyslogLocal>> SyslogQueue<S>

Source

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

Source§

impl<F, D, S> SyslogQueue<S, F, D>

Source

pub fn openlog_with( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap: D, ) -> SyRes<SyslogQueue<S, F, D>>

Trait Implementations§

Source§

impl<F: SyslogFormatter, D: SyslogDestination, S: SyslogQueueChannel<F, D>> AsyncSyslogQueueApi<F, D> for SyslogQueue<S, F, D>

Source§

async fn a_setlogmask(&self, logmask: i32) -> SyRes<i32>

Sets the logmask to filter out the syslog calls. This function behaves differently as it behaves in syslog_sync.rs or syslog_async.rs. It may return an error if: syslog thread had exit and some thread calls this function. Or something happened with channel. 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§

async fn a_closelog(&self) -> SyRes<()>

Closes connection to the syslog server

Source§

async fn a_syslog(&self, pri: Priority, fmt: F)

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

§Arguments
  • pri - a priority Priority

  • fmt - a program’s message to be sent as payload. The message is encoded with the SyslogFormatter and may be different for different formatters.

Source§

async fn a_reconnect(&self) -> SyRes<()>

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

§Returns

A Result is retured as SyRes.

Source§

async fn a_update_tap_data(&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

Source§

async fn a_connectlog(&mut self) -> SyRes<()>

Requests to connect to remote server.
Source§

async fn a_change_identity(&self, ident: &str) -> SyRes<()>

This function can be used to update the facility name, for example after fork(). Read more
Source§

impl<S, F, D> Clone for SyslogQueue<S, F, D>

Source§

fn clone(&self) -> SyslogQueue<S, F, D>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S, F, D> Debug for SyslogQueue<S, F, D>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<F, D, S> Drop for SyslogQueue<S, F, D>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<F: SyslogFormatter, D: SyslogDestination, S: SyslogQueueChannel<F, D>> StreamableSyslogApi<D, F, SyslogQueue<S, F, D>> for SyslogQueue<S, F, D>

Source§

impl<F: SyslogFormatter, D: SyslogDestination, S: SyslogQueueChannel<F, D>> SyslogApi<F, D> for SyslogQueue<S, F, D>

Source§

fn connectlog(&self) -> SyRes<()>

Connects the current instance to the syslog server (destination).
Source§

fn setlogmask(&self, logmask: i32) -> SyRes<i32>

Sets the logmask to filter out the syslog calls. Read more
Source§

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

Closes connection to the syslog server (destination).
Source§

fn syslog(&self, pri: Priority, fmt: F)

Similar to libc, syslog() sends data to syslog server. Read more
Source§

fn change_identity(&self, ident: &str) -> SyRes<()>

This function can be used to update the facility name, for example after fork(). Read more
Source§

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

Re-opens the connection to the syslog server. Can be used to rotate logs(handle SIGHUP). Read more
Source§

fn update_tap_data(&self, tap_data: D) -> SyRes<()>

Updates the instance’s socket. tap_data [TapTypeData] should be of the same variant (type) as current.
Source§

impl<F, D, S> Send for SyslogQueue<S, F, D>

Source§

impl<F, D, S> Sync for SyslogQueue<S, F, D>

Auto Trait Implementations§

§

impl<S, F, D> Freeze for SyslogQueue<S, F, D>
where <S as SyslogQueueChannel<F, D>>::ChannelSnd: Freeze,

§

impl<S, F, D> RefUnwindSafe for SyslogQueue<S, F, D>

§

impl<S, F, D> Unpin for SyslogQueue<S, F, D>
where <S as SyslogQueueChannel<F, D>>::ChannelSnd: Unpin, F: Unpin, D: Unpin,

§

impl<S, F, D> UnwindSafe for SyslogQueue<S, F, D>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.