Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. extern crate log;
  2. extern crate syslog;
  3.  
  4. use syslog::{Facility, Error, Formatter3164, LoggerBackend};
  5. extern crate hostname;
  6. use std::fmt::Display;
  7.  
  8. #[derive(Debug)]
  9. pub struct Config<T> {
  10. pub hostname: String,
  11. pub logger: T
  12. }
  13.  
  14.  
  15. impl<T: Display> Config<syslog::Logger<LoggerBackend, T, Formatter3164>> {
  16. pub fn new() -> Self{
  17. let formatter = Formatter3164 {
  18. facility: Facility::LOG_USER,
  19. hostname: None,
  20. process: "SomeProg".into(),
  21. pid: 0,
  22. };
  23. Config{
  24. hostname: hostname::get_hostname().unwrap().to_string(),
  25. logger: syslog::unix(formatter).unwrap()
  26. }
  27.  
  28. }
  29. }
  30.  
  31.  
  32. fn main() {
  33. let mut config: Config<syslog::Logger<LoggerBackend, String, Formatter3164>> = Config::new();
  34. config.logger.debug("THis is new debug message".to_string());
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement