Struct syslog_tls::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>
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)
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_tls::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");
}
}
}
More examples
examples/rfc5424.rs (lines 17-21)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn main() {
let formatter = Formatter5424 {
facility: Facility::LOG_USER,
hostname: None,
process: "myprogram".into(),
pid: 0,
};
match syslog_tls::unix(formatter) {
Err(e) => println!("impossible to connect to syslog: {:?}", e),
Ok(mut writer) => {
writer
.err(SyslogMessage {
message_level: 1,
structured: Vec::new(),
message: "hello world".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> RefUnwindSafe for Logger<Backend, Formatter>where
Backend: RefUnwindSafe,
Formatter: 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
Backend: UnwindSafe,
Formatter: 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