Struct syslog::Logger

source ·
pub struct Logger<Backend: Write, Formatter> {
    pub formatter: Formatter,
    pub backend: Backend,
}
Expand description

Main logging structure

Fields§

§formatter: Formatter§backend: Backend

Implementations§

source§

impl<W: Write, F> Logger<W, F>

source

pub fn new(backend: W, formatter: F) -> Self

source

pub fn emerg<T>(&mut self, message: T) -> Result<()>
where F: LogFormat<T>,

source

pub fn alert<T>(&mut self, message: T) -> Result<()>
where F: LogFormat<T>,

source

pub fn crit<T>(&mut self, message: T) -> Result<()>
where F: LogFormat<T>,

source

pub fn err<T>(&mut self, message: T) -> Result<()>
where F: LogFormat<T>,

Examples found in repository?
examples/rfc5424.rs (line 18)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let formatter = Formatter5424 {
        facility: Facility::LOG_USER,
        hostname: None,
        process: "myprogram".into(),
        pid: 0,
    };

    match syslog::unix(formatter) {
        Err(e) => println!("impossible to connect to syslog: {:?}", e),
        Ok(mut writer) => {
            writer
                .err((1, HashMap::new(), "hello world"))
                .expect("could not write error message");
        }
    }
}
More examples
Hide additional examples
examples/write.rs (line 17)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
fn main() {
    let formatter = Formatter3164 {
        facility: Facility::LOG_USER,
        hostname: None,
        process: "myprogram".into(),
        pid: 0,
    };

    match syslog::unix(formatter) {
        Err(e) => println!("impossible to connect to syslog: {:?}", e),
        Ok(mut writer) => {
            writer
                .err("hello world")
                .expect("could not write error message");
            writer
                .err("hello all".to_string())
                .expect("could not write error message");
        }
    }
}
source

pub fn warning<T>(&mut self, message: T) -> Result<()>
where F: LogFormat<T>,

source

pub fn notice<T>(&mut self, message: T) -> Result<()>
where F: LogFormat<T>,

source

pub fn info<T>(&mut self, message: T) -> Result<()>
where F: LogFormat<T>,

source

pub fn debug<T>(&mut self, message: T) -> Result<()>
where F: LogFormat<T>,

Auto Trait Implementations§

§

impl<Backend, Formatter> Freeze for Logger<Backend, Formatter>
where Formatter: Freeze, Backend: Freeze,

§

impl<Backend, Formatter> RefUnwindSafe for Logger<Backend, Formatter>
where Formatter: RefUnwindSafe, Backend: RefUnwindSafe,

§

impl<Backend, Formatter> Send for Logger<Backend, Formatter>
where Formatter: Send, Backend: Send,

§

impl<Backend, Formatter> Sync for Logger<Backend, Formatter>
where Formatter: Sync, Backend: Sync,

§

impl<Backend, Formatter> Unpin for Logger<Backend, Formatter>
where Formatter: Unpin, Backend: Unpin,

§

impl<Backend, Formatter> UnwindSafe for Logger<Backend, Formatter>
where Formatter: UnwindSafe, Backend: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.