January 2019
Intermediate to advanced
520 pages
14h 32m
English
The main type is the LogActor struct, which contains a Logger instance in the writer field:
pub struct LogActor { writer: Logger<LoggerBackend, String, Formatter3164>,}
We'll use this logger in the Handler trait implementation to write messages, but now we need a constructor for our struct, because we have to configure Logger on start:
impl LogActor { pub fn new() -> Self { let formatter = Formatter3164 { facility: Facility::LOG_USER, hostname: None, process: "rust-microservice".into(), pid: 0, }; let writer = syslog::unix(formatter).unwrap(); Self { writer, } } }
We added new method that fills the Formatter3164 struct with the Facility value and process name. Other fields are set to blank values. We create a Logger instance by calling ...
Read now
Unlock full access