Conditional logging destination
This commit is contained in:
parent
1ae5d2b49f
commit
445b22fecd
1 changed files with 13 additions and 3 deletions
|
@ -16,7 +16,10 @@ impl InterfaceConfig {
|
||||||
let cfg: Self = match confy::load(env!("CARGO_PKG_NAME"),"interfaces") {
|
let cfg: Self = match confy::load(env!("CARGO_PKG_NAME"),"interfaces") {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("[ERROR] {}", e);
|
match connected_to_journal() {
|
||||||
|
true => error!("[ERROR] {e}"),
|
||||||
|
false => eprintln!("[ERROR] {e}")
|
||||||
|
}
|
||||||
return Err(Box::new(e));
|
return Err(Box::new(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -75,7 +78,11 @@ impl ZoneConfig {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
warn!("[WARN] Subdirectory in zones.d detected, this should not be the case");
|
let warn_msg = "Subdirectory in zones.d detected, this should not be the case";
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => warn!("[WARN] {warn_msg}"),
|
||||||
|
false => eprintln!("[WARN] {warn_msg}"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let zone_config_path = format!("zones.d/{}", path.file_stem()
|
let zone_config_path = format!("zones.d/{}", path.file_stem()
|
||||||
|
@ -84,7 +91,10 @@ impl ZoneConfig {
|
||||||
match confy::load(env!("CARGO_PKG_NAME"), zone_config_path.as_str()) {
|
match confy::load(env!("CARGO_PKG_NAME"), zone_config_path.as_str()) {
|
||||||
Ok(data) => zone_configs.push(data),
|
Ok(data) => zone_configs.push(data),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("[ERROR] {}", e);
|
match connected_to_journal() {
|
||||||
|
true => error!("[ERROR] {e}"),
|
||||||
|
false => eprintln!("[ERROR] {e}"),
|
||||||
|
}
|
||||||
return Err(Box::new(e));
|
return Err(Box::new(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue