desktop: Do not store logs in config directory

Logs are non-essential and can be removed, contrary to config files.
This patch changes the log directory from config dir to cache dir.
This commit is contained in:
Kamil Jarosz 2024-09-14 10:15:30 +02:00 committed by TÖRÖK Attila
parent b59ee2f91b
commit e2e826259d
1 changed files with 6 additions and 3 deletions

View File

@ -155,11 +155,14 @@ async fn main() -> Result<(), Error> {
let opt = Opt::parse();
let preferences = GlobalPreferences::load(opt.clone())?;
let logs_path = &preferences.cli.cache_directory.join("log");
let log_path = preferences.log_filename_pattern().create_path(logs_path);
if let Some(parent) = log_path.parent() {
std::fs::create_dir_all(parent)?;
}
// [NA] `_guard` cannot be `_` or it'll immediately drop
// https://docs.rs/tracing-appender/latest/tracing_appender/non_blocking/index.html
let log_path = preferences
.log_filename_pattern()
.create_path(&preferences.cli.config);
let (non_blocking_file, _file_guard) = tracing_appender::non_blocking(File::create(log_path)?);
let (non_blocking_stdout, _stdout_guard) = tracing_appender::non_blocking(std::io::stdout());