pub struct AsyncSyslog<D = SyslogLocal, S = AsyncSyslogShared<DefaultSyslogFormatter>>(/* private fields */)
where
D: SyslogDestination,
S: AsyncSyslogApi<D>;
Expand description
A main instance of the Syslog client.
-
D
- a SyslogDestination instance which is either: SyslogLocal, SyslogFile, [SyslogNet], SyslogTls. By default aSyslogLocal
is set. -
S
- a [AsyncSyslogApi] sybsystem. It is either AsyncSyslogShared or AsyncSyslogQueue with the same ‘F’ - formatter type. By default a AsyncSyslogShared is set.
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.
Sourcepub async fn openlog_with(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility,
net_tap: D,
) -> SyRes<AsyncSyslog<D, AsyncSyslogShared<F, D>>>
pub async fn openlog_with( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap: D, ) -> SyRes<AsyncSyslog<D, AsyncSyslogShared<F, D>>>
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) -> SyRes<i32>
pub async fn 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)
Sourcepub async fn change_identity(&self, ident: &str) -> SyRes<()>
pub async fn change_identity(&self, ident: &str) -> SyRes<()>
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
Source§impl<D: SyslogDestination, F: SyslogFormatter + Sync> AsyncSyslog<D, AsyncSyslogQueue<F, D>>
A queue implementation.
impl<D: SyslogDestination, F: SyslogFormatter + Sync> AsyncSyslog<D, AsyncSyslogQueue<F, D>>
A queue implementation.
Sourcepub async fn attach_queue(
dest: &Syslog<D, SyslogQueue<F, D>>,
) -> SyRes<AsyncSyslog<D, AsyncSyslogQueue<F, D>>>
pub async fn attach_queue( dest: &Syslog<D, SyslogQueue<F, D>>, ) -> SyRes<AsyncSyslog<D, AsyncSyslogQueue<F, D>>>
Attaches to the SyslogQueue so the async instance of syslog will write to the same instance with sync portion.
§Arguments
dest
- a Syslog instance of type SyslogQueue. TheD
SyslogDestination of instance does shoud be of the same type as insync protion
.
§Returns
A SyRes is returned. The Result::Err will be returned only of thread which serves the message queue panics or was not started.
Sourcepub async fn setlogmask(&self, logmask: i32) -> SyRes<i32>
pub async fn 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)
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