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>
impl<W: Write, F> Logger<W, F>
pub fn new(backend: W, formatter: F) -> Self
pub fn emerg<T>(&mut self, message: T) -> Result<()>where
F: LogFormat<T>,
pub fn alert<T>(&mut self, message: T) -> Result<()>where
F: LogFormat<T>,
pub fn crit<T>(&mut self, message: T) -> Result<()>where
F: LogFormat<T>,
sourcepub fn err<T>(&mut self, message: T) -> Result<()>where
F: LogFormat<T>,
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
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");
}
}
}
pub fn warning<T>(&mut self, message: T) -> Result<()>where
F: LogFormat<T>,
pub fn notice<T>(&mut self, message: T) -> Result<()>where
F: LogFormat<T>,
pub fn info<T>(&mut self, message: T) -> Result<()>where
F: LogFormat<T>,
pub fn debug<T>(&mut self, message: T) -> Result<()>where
F: LogFormat<T>,
Auto Trait Implementations§
impl<Backend, Formatter> Freeze for Logger<Backend, Formatter>
impl<Backend, Formatter> RefUnwindSafe for Logger<Backend, Formatter>where
Formatter: RefUnwindSafe,
Backend: RefUnwindSafe,
impl<Backend, Formatter> Send for Logger<Backend, Formatter>
impl<Backend, Formatter> Sync for Logger<Backend, Formatter>
impl<Backend, Formatter> Unpin for Logger<Backend, Formatter>
impl<Backend, Formatter> UnwindSafe for Logger<Backend, Formatter>where
Formatter: UnwindSafe,
Backend: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more