Skip to content

Commit

Permalink
changed default log file to ~/.odilia.log (#151)
Browse files Browse the repository at this point in the history
* changed default log file to ~/.odilia.log

* updated to use env instead of dirs home_dir, need to create odilia directory in .local/share

* changed log file to XDG_DATA

* removed TODOs

* changed log path

---------

Co-authored-by: Ellis Haker <[email protected]>
  • Loading branch information
petrovvvv and ehaker1 authored May 29, 2024
1 parent 23797bd commit f944d9d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ thiserror = "1.0.37"
zbus.workspace = true
serde_plain.workspace = true
figment = "0.10.15"
xdg = "2.4.1"
14 changes: 9 additions & 5 deletions common/src/settings/log.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

use serde::{Deserialize, Serialize};
///structure used for all the configurable options related to logging
#[derive(Debug, Serialize, Deserialize)]
#[allow(clippy::module_name_repetitions)]
Expand All @@ -16,10 +16,14 @@ pub struct LogSettings {
}
impl Default for LogSettings {
fn default() -> Self {
Self {
level: "info".to_owned(),
logger: LoggingKind::File("/var/log/odilia.log".into()),
}
let xdg_dirs = xdg::BaseDirectories::with_prefix("odilia").expect(
"unable to find the odilia config directory according to the xdg dirs specification",
);
let log_path = xdg_dirs
.place_state_file("odilia.log")
.expect("unable to place log file");

Self { level: "info".to_owned(), logger: LoggingKind::File(log_path) }
}
}

Expand Down

0 comments on commit f944d9d

Please sign in to comment.