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
-
S
- a SyslogQueueChannel a MPSC provider. -
F
- a SyslogFormatter which sets the instance which would format the message. -
D
- a SyslogDestination instance which is either: SyslogLocal, [SyslogFile], [SyslogNet], [SyslogTls]. By default aSyslogLocal
is selected.
Implementations§
Source§impl<S: SyslogQueueChannel<DefaultSyslogFormatter, SyslogLocal>> SyslogQueue<S>
impl<S: SyslogQueueChannel<DefaultSyslogFormatter, SyslogLocal>> SyslogQueue<S>
pub fn openlog( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap: SyslogLocal, ) -> SyRes<Self>
Source§impl<F, D, S> SyslogQueue<S, F, D>
impl<F, D, S> SyslogQueue<S, F, D>
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>
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>
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<()>
async fn a_closelog(&self) -> SyRes<()>
Closes connection to the syslog server
Source§async fn a_syslog(&self, pri: Priority, fmt: F)
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<()>
async fn a_reconnect(&self) -> SyRes<()>
Performs the reconnection to the syslog server or file re-open.
§Returns
-
Result::Ok - with empty inner type.
-
Result::Err - an error code and description
Source§async fn a_update_tap_data(&self, new_tap: D) -> SyRes<()>
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
new_tap
- a consumed instance of typeD
SyslogDestination
§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<()>
async fn a_connectlog(&mut self) -> SyRes<()>
Source§impl<S, F, D> Clone for SyslogQueue<S, F, D>where
F: SyslogFormatter + Clone,
D: SyslogDestination + Clone,
S: SyslogQueueChannel<F, D> + Clone,
S::ChannelSnd: Clone,
impl<S, F, D> Clone for SyslogQueue<S, F, D>where
F: SyslogFormatter + Clone,
D: SyslogDestination + Clone,
S: SyslogQueueChannel<F, D> + Clone,
S::ChannelSnd: Clone,
Source§fn clone(&self) -> SyslogQueue<S, F, D>
fn clone(&self) -> SyslogQueue<S, F, D>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<S, F, D> Debug for SyslogQueue<S, F, D>where
F: SyslogFormatter + Debug,
D: SyslogDestination + Debug,
S: SyslogQueueChannel<F, D> + Debug,
S::ChannelSnd: Debug,
impl<S, F, D> Debug for SyslogQueue<S, F, D>where
F: SyslogFormatter + Debug,
D: SyslogDestination + Debug,
S: SyslogQueueChannel<F, D> + Debug,
S::ChannelSnd: Debug,
Source§impl<F, D, S> Drop for SyslogQueue<S, F, D>
impl<F, D, S> Drop for SyslogQueue<S, F, D>
Source§impl<F: SyslogFormatter, D: SyslogDestination, S: SyslogQueueChannel<F, D>> StreamableSyslogApi<D, F, SyslogQueue<S, F, D>> for SyslogQueue<S, F, D>
impl<F: SyslogFormatter, D: SyslogDestination, S: SyslogQueueChannel<F, D>> StreamableSyslogApi<D, F, SyslogQueue<S, F, D>> for SyslogQueue<S, F, D>
fn make_stream(&self, pri: Priority) -> Box<dyn SyslogStream>
Source§impl<F: SyslogFormatter, D: SyslogDestination, S: SyslogQueueChannel<F, D>> SyslogApi<F, D> for SyslogQueue<S, F, D>
impl<F: SyslogFormatter, D: SyslogDestination, S: SyslogQueueChannel<F, D>> SyslogApi<F, D> for SyslogQueue<S, F, D>
Source§fn connectlog(&self) -> SyRes<()>
fn connectlog(&self) -> SyRes<()>
Source§fn setlogmask(&self, logmask: i32) -> SyRes<i32>
fn setlogmask(&self, logmask: i32) -> SyRes<i32>
Source§fn syslog(&self, pri: Priority, fmt: F)
fn syslog(&self, pri: Priority, fmt: F)
Source§fn change_identity(&self, ident: &str) -> SyRes<()>
fn change_identity(&self, ident: &str) -> SyRes<()>
Source§fn reconnect(&self) -> SyRes<()>
fn reconnect(&self) -> SyRes<()>
Source§fn update_tap_data(&self, tap_data: D) -> SyRes<()>
fn update_tap_data(&self, tap_data: D) -> SyRes<()>
tap_data
[TapTypeData] should be of
the same variant (type) as current.