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 aSyslogLocal
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
impl AsyncSyslog
Sourcepub async fn openlog(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility,
net_tap: SyslogLocal,
) -> SyRes<Self>
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:
-
Result::Ok - with instance
-
Result::Err - with error description.
Source§impl<F, D, IO, MUX> AsyncSyslog<D, F, IO, MUX>where
F: SyslogFormatter + Sync,
D: AsyncSyslogDestination,
MUX: AsyncMutex<F, D, AsyncSyslogInternal<F, D, IO>>,
IO: AsyncSyslogInternalIO,
A shared implementation.
impl<F, D, IO, MUX> AsyncSyslog<D, F, IO, MUX>where
F: SyslogFormatter + Sync,
D: AsyncSyslogDestination,
MUX: AsyncMutex<F, D, AsyncSyslogInternal<F, D, IO>>,
IO: AsyncSyslogInternalIO,
A shared implementation.
Sourcepub async fn openlog_with(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility,
net_tap: D,
) -> SyRes<AsyncSyslog<D, F, IO, MUX>>
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 specificD
instance which contains infomation about the destination server. Seesyslog_provider.rs
.
§Returns
A SyRes is returned (Result) with:
-
Result::Ok - with instance
-
Result::Err - with error description.
Sourcepub async fn setlogmask(&self, logmask: i32) -> i32
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)
Sourcepub async fn change_identity(&self, ident: &str)
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.
Sourcepub async fn vsyslog<M: AsRef<str>>(&self, pri: Priority, fmt: M)
pub async fn vsyslog<M: AsRef<str>>(&self, pri: Priority, fmt: M)
Sends message to syslog (same as syslog
).
Sourcepub async fn reconnect(&self) -> SyRes<()>
pub async fn 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
Sourcepub async fn update_tap(&self, new_tap: D) -> SyRes<()>
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
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