Struct SyslogShared

Source
pub struct SyslogShared<F: SyslogFormatter = DefaultSyslogFormatter, D: SyslogDestination = SyslogLocal> { /* private fields */ }
Expand description

A single instance shared between all threads. A Mutex is used to guard the instance.

For this isntance a SyslogApi and StreamableSyslogApi are implemented.

§Generics

  • 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 a SyslogLocal is selected.

Implementations§

Source§

impl SyslogShared

Source

pub fn openlog( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap_prov: SyslogLocal, ) -> SyRes<Self>

Opens a default connection to the local syslog server with default formatter.

In order to access the syslog API, use the SyslogApi.

§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_prov - a SyslogLocal instance with configuration.

§Returns

A SyRes is returned (Result) with:

Source§

impl<F: SyslogFormatter, D: SyslogDestination> SyslogShared<F, D>

Source

pub fn openlog_with( ident: Option<&str>, logstat: LogStat, facility: LogFacility, net_tap_prov: D, ) -> SyRes<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.

In order to access the syslog API, use the SyslogApi.

§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_prov - a destination server. A specific D instance which contains infomation about the destination server. See syslog_provider.rs.

§Returns

A SyRes is returned (Result) with:

Trait Implementations§

Source§

impl<F: Clone + SyslogFormatter, D: Clone + SyslogDestination> Clone for SyslogShared<F, D>

Source§

fn clone(&self) -> SyslogShared<F, D>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + SyslogFormatter, D: Debug + SyslogDestination> Debug for SyslogShared<F, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: SyslogFormatter, D: SyslogDestination> StreamableSyslogApi<D, F, SyslogShared<F, D>> for SyslogShared<F, D>

Source§

impl<F: SyslogFormatter, D: SyslogDestination> SyslogApi<F, D> for SyslogShared<F, D>

Source§

fn change_identity(&self, ident: &str) -> 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 connectlog(&self) -> SyRes<()>

Connects the current instance to the syslog server (destination).
Source§

fn setlogmask(&self, logmask: i32) -> SyRes<i32>

Sets the logmask to filter out the syslog calls. Read more
Source§

fn closelog(&self) -> SyRes<()>

Closes connection to the syslog server (destination).
Source§

fn syslog(&self, pri: Priority, fmt: F)

Similar to libc, syslog() sends data to syslog server. Read more
Source§

fn reconnect(&self) -> SyRes<()>

Re-opens the connection to the syslog server. Can be used to rotate logs(handle SIGHUP). Read more
Source§

fn update_tap_data(&self, tap_data: D) -> SyRes<()>

Updates the instance’s socket. tap_data [TapTypeData] should be of the same variant (type) as current.
Source§

impl<F: SyslogFormatter, D: SyslogDestination> Send for SyslogShared<F, D>

Source§

impl<F: SyslogFormatter, D: SyslogDestination> Sync for SyslogShared<F, D>

Auto Trait Implementations§

§

impl<F, D> Freeze for SyslogShared<F, D>

§

impl<F, D> RefUnwindSafe for SyslogShared<F, D>

§

impl<F, D> Unpin for SyslogShared<F, D>

§

impl<F, D> UnwindSafe for SyslogShared<F, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.