use xdg convention for log file location putting it in .cache (see #27)

This commit is contained in:
Stephan Dilly 2020-04-22 14:24:26 +02:00
parent aa1c54d366
commit 39479c5d13
2 changed files with 8 additions and 3 deletions

View file

@ -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

View file

@ -152,8 +152,8 @@ fn start_terminal<W: Write>(
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();