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 send<T>(&mut self, severity: Severity, message: &T) -> Result<()>where
F: LogFormat<T>,
pub fn send_at<T>(
&mut self,
severity: Severity,
time: OffsetDateTime,
message: &T,
) -> Result<()>where
F: LogFormat<T>,
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/write.rs (line 17)
5fn main() {
6 let formatter = Formatter3164 {
7 facility: Facility::LOG_USER,
8 hostname: None,
9 process: "myprogram".into(),
10 pid: 0,
11 };
12
13 match syslog_tls::unix(formatter) {
14 Err(e) => println!("impossible to connect to syslog: {:?}", e),
15 Ok(mut writer) => {
16 writer
17 .err("hello world")
18 .expect("could not write error message");
19 writer
20 .err("hello all".to_string())
21 .expect("could not write error message");
22 }
23 }
24}
More examples
examples/rfc5424.rs (lines 17-21)
5fn main() {
6 let formatter = Formatter5424 {
7 facility: Facility::LOG_USER,
8 hostname: None,
9 process: "myprogram".into(),
10 pid: 0,
11 };
12
13 match syslog_tls::unix(formatter) {
14 Err(e) => println!("impossible to connect to syslog: {:?}", e),
15 Ok(mut writer) => {
16 writer
17 .err(SyslogMessage {
18 message_level: 1,
19 structured: Vec::new(),
20 message: "hello world".to_string(),
21 })
22 .expect("could not write error message");
23 }
24 }
25}
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