Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store logs in XDG_STATE_HOME by default #90

Closed
getawaywithrmdir opened this issue May 1, 2024 · 3 comments
Closed

Store logs in XDG_STATE_HOME by default #90

getawaywithrmdir opened this issue May 1, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@getawaywithrmdir
Copy link

The part you want to Enhancement
I would love for logs to be stored in XDG_STATE_HOME (if it exists) by default.

Why it is necessary to enhancement
None of the other XDG "save-to" locations is suitable for history/logs:

  • XDG_CONFIG_HOME and XDG_RUNTIME_DIR are the most obviously inappropriate choices, so I won't explain further here.
  • XDG_DATA_HOME is for an app's user-specific files they might want to sync across installations—generally not the case for logs/history.
  • XDG_CACHE_HOME, like any cache directory, should only ever contain files/information that can be recreated in full if deleted. Users are often told it is safe to clean their cache folders because apps are only supposed to store stuff there temporarily, for faster runtimes or whatever, so if an app stores anything there that cannot be recreated (like history/logs), it can very easily get deleted unintentionally by a user or their cache-cleaning app/script/OS/etc. If the history is actually stored in full elsewhere and is just cached here for some reason, then of course that's fine.
  • XDG_STATE_HOME was added to the XDG base directory spec in 2022 to solve this exact problem :).

Additional context
I LOVE that you've been increasing your XDG support recently (#27, #23), and I really like this app :).

I believe you are using rkoesters/xdg for basedir, so I did first ask them to add support, but who knows when/if they'll be able to get to it:

XDG_STATE_HOME description from the XDG base directory specification:

$XDG_STATE_HOME defines the base directory relative to which user-specific state files should be stored. If $XDG_STATE_HOME is either not set or empty, a default equal to $HOME/.local/state should be used.

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

  • actions history (logs, history, recently used files, …)
  • current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

Lastly, I do work on several linux machines, but my daily driver for now is a Mac—and I (and many others!) set the XDG base directory environment variables even there to make it easier to organize all my files (I've even encountered overly-hopeful people who set them on Windows...). Many applications support this (check for environment variable existence, and if not set check the OS and use its defaults), but not all...so bonus points if you're able to accommodate people like me and do likewise 😁.

@yorukot
Copy link
Owner

yorukot commented May 3, 2024

Wow thank you for adding such detailed information to this!!

@yorukot
Copy link
Owner

yorukot commented May 6, 2024

Create new PR on xdg/basedir rkoesters/xdg#16

@yorukot
Copy link
Owner

yorukot commented May 8, 2024

@getawaywithrmdir Thanks for the advice!

Updated it at c778040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants