Skip to content

Commit

Permalink
use xdg convention for log file location putting it in .cache (see #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed Apr 22, 2020
1 parent aa1c54d commit 39479c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 39479c5

Please sign in to comment.