Initial commit
- rough filestructure - first simplistic daemon
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Parsing the config file
|
||||
//
|
||||
|
||||
use std::fs;
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct HuskConfig {
|
||||
logfile_config: Option<String>,
|
||||
}
|
||||
|
||||
impl HuskConfig {
|
||||
|
||||
pub fn load(path: &String) -> Option<Self> {
|
||||
match fs::read_to_string(path) {
|
||||
Ok(data) => {
|
||||
match toml::from_str(data.as_str()) {
|
||||
Ok(configuration) => Some(configuration),
|
||||
Err(e) => {
|
||||
eprintln!("Error while parsing config file: {:?}", e);
|
||||
None
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
eprintln!("Error while reading config file: {:?}", e);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn logfile_config(&self) -> String {
|
||||
match &self.logfile_config {
|
||||
Some(c) => c.clone(),
|
||||
None => {
|
||||
eprintln!("Using logging configuration from 'log4rs.yml'");
|
||||
"log4rs.yml".to_string()
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user