From 39479c5d1394cab237febb6d25b19ba3edbe3ee4 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 22 Apr 2020 14:24:26 +0200 Subject: [PATCH] use xdg convention for log file location putting it in .cache (see #27) --- README.md | 7 ++++++- src/main.rs | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8b2060a..41dc5c96 100644 --- a/README.md +++ b/README.md @@ -63,11 +63,16 @@ cargo install gitui # diagnostics: -to enable logging to `~/.gitui/gitui.log`: +to enable logging: ``` GITUI_LOGGING=true gitui ``` +this will log to: +* `$HOME/Library/Caches/gitui/gitui.log` (mac) +* `$XDG_CACHE_HOME/gitui/gitui.log` (linux using `XDG`) +* `$HOME/.cache/gitui/gitui.log` (linux) + # inspiration * https://github.com/jesseduffield/lazygit diff --git a/src/main.rs b/src/main.rs index a28fbc8b..359a0b1f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -152,8 +152,8 @@ fn start_terminal( fn setup_logging() { if env::var("GITUI_LOGGING").is_ok() { - let mut path = dirs::home_dir().unwrap(); - path.push(".gitui"); + let mut path = dirs::cache_dir().unwrap(); + path.push("gitui"); path.push("gitui.log"); fs::create_dir(path.parent().unwrap()).unwrap_or_default();