Struct syslog_rs::sync::syslog_sync_queue::Syslog
source · pub struct Syslog { /* private fields */ }Expand description
A common instance which describes the syslog state
Trait Implementations§
source§impl SyslogExt for Syslog
impl SyslogExt for Syslog
source§fn openlog_custom<P>(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility,
sock_path: P
) -> SyRes<Self>where
P: AsRef<Path>,
fn openlog_custom<P>(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility,
sock_path: P
) -> SyRes<Self>where
P: AsRef<Path>,
source§fn change_identity<I: AsRef<str>>(&self, ident: I) -> SyRes<()>
fn change_identity<I: AsRef<str>>(&self, ident: I) -> SyRes<()>
This function can be used to update the facility name, for example after fork().
Arguments
ident- a new identity (up to 48 UTF8 chars)
source§fn make_stream(&self, pri: Priority) -> Box<dyn SyslogStream>
fn make_stream(&self, pri: Priority) -> Box<dyn SyslogStream>
Creates an instance which is implements core::fmt::Write.
Arguments
pri- a priority Priority (can be updated)
Returns
Error not supported
source§impl SyslogStd for Syslog
impl SyslogStd for Syslog
source§fn openlog(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility
) -> SyRes<Self>
fn openlog(
ident: Option<&str>,
logstat: LogStat,
facility: LogFacility
) -> SyRes<Self>
As in a libc, this function initializes the syslog instance. The main difference with realization in C is it returns the instance to program used this crate. This structure implements the Send and Sync so it does not require any additional synchonization.
Arguments
-
ident- a identification of the sender. If not set, the crate will determine automatically! -
logstat- sets up the syslog behaviour. Use LogStat -
facility- a syslog facility. Use LogFacility
Returns
- A SyRes with instance or Err()
Example
Syslog::openlog(
Some("test1"),
LogStat::LOG_NDELAY | LogStat::LOG_PID,
LogFacility::LOG_DAEMON);source§fn setlogmask(&self, logmask: i32) -> SyRes<i32>
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)