Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate log;
- extern crate syslog;
- use syslog::{Facility, Error, Formatter3164, LoggerBackend};
- extern crate hostname;
- use std::fmt::Display;
- #[derive(Debug)]
- pub struct Config<T> {
- pub hostname: String,
- pub logger: T
- }
- impl<T: Display> Config<syslog::Logger<LoggerBackend, T, Formatter3164>> {
- pub fn new() -> Self{
- let formatter = Formatter3164 {
- facility: Facility::LOG_USER,
- hostname: None,
- process: "SomeProg".into(),
- pid: 0,
- };
- Config{
- hostname: hostname::get_hostname().unwrap().to_string(),
- logger: syslog::unix(formatter).unwrap()
- }
- }
- }
- fn main() {
- let mut config: Config<syslog::Logger<LoggerBackend, String, Formatter3164>> = Config::new();
- config.logger.debug("THis is new debug message".to_string());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement