pub struct Syslog<D = SyslogLocal, S = SyslogShared<DefaultSyslogFormatter, D>>(/* private fields */)
where
D: SyslogDestination,
S: SyslogApi<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 [SyslogApi] sybsystem. It is either SyslogShared or SyslogQueue with the same ‘F’ - formatter type. By default a SyslogShared is set.
Implementations§
Source§impl Syslog
impl Syslog
Sourcepub fn openlog(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility,
net_tap: SyslogLocal,
) -> SyRes<Self>
pub fn openlog( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap: SyslogLocal, ) -> SyRes<Self>
Opens a default 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 fn openlog_with(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility,
net_tap: D,
) -> SyRes<Syslog<D, SyslogShared<F, D>>>
pub fn openlog_with( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap: D, ) -> SyRes<Syslog<D, SyslogShared<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 fn setlogmask(&self, logmask: i32) -> SyRes<i32>
pub 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 fn change_identity(&self, ident: &str) -> SyRes<()>
pub 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 fn vsyslog<M: AsRef<str>>(&self, pri: Priority, fmt: M)
pub fn vsyslog<M: AsRef<str>>(&self, pri: Priority, fmt: M)
Sends message to syslog (same as syslog
).
Sourcepub fn reconnect(&self) -> SyRes<()>
pub 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 fn update_tap(&self, new_tap: D) -> SyRes<()>
pub 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
Sourcepub fn make_stream(&self, pri: Priority) -> Box<dyn SyslogStream>
pub fn make_stream(&self, pri: Priority) -> Box<dyn SyslogStream>
Derives from active syslog intance an fmt::Write instance.
A boxed dyn
instance of SyslogStream is returned.
Source§impl<D: SyslogDestination, F: SyslogFormatter> Syslog<D, SyslogQueue<F, D>>
A queued implementation.
impl<D: SyslogDestination, F: SyslogFormatter> Syslog<D, SyslogQueue<F, D>>
A queued implementation.
Sourcepub fn openlog_with(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility,
net_tap: D,
) -> SyRes<Syslog<D, SyslogQueue<F, D>>>
pub fn openlog_with( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap: D, ) -> SyRes<Syslog<D, SyslogQueue<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 fn setlogmask(&self, logmask: i32) -> SyRes<i32>
pub 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 fn vsyslog<M: AsRef<str>>(&self, pri: Priority, fmt: M)
pub fn vsyslog<M: AsRef<str>>(&self, pri: Priority, fmt: M)
Sends message to syslog (same as syslog
).
Sourcepub fn reconnect(&self) -> SyRes<()>
pub 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 fn update_tap(&self, new_tap: D) -> SyRes<()>
pub 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
Sourcepub fn make_stream(&self, pri: Priority) -> Box<dyn SyslogStream>
pub fn make_stream(&self, pri: Priority) -> Box<dyn SyslogStream>
Derives from active syslog intance an fmt::Write instance.
A boxed dyn
instance of SyslogStream is returned.