EDMarketConnector icon indicating copy to clipboard operation
EDMarketConnector copied to clipboard

Follow xdg base directory specification for log files (instead of `$TMPDIR`)

Open ultimatespirit opened this issue 1 year ago • 2 comments

Describe the enhancement

Would it be possible to change the log file directory location (currently $TMPDIR) to use the XDG Base Directory Specification? Or at least have an option to change it in the configuration file, or at runtime (via a flag, not an env variable) if the log directory info is needed before configurations can be read.

It's not clear to me how transient those log files are meant to be (since by default they reside in /tmp which would get cleared every reboot at least), so either $XDG_STATE_HOME (more persistent, but not generally a candidate for backups) or $XDG_CACHE_HOME (closest to /tmp) would fit it seems.

For what it's worth, since presumably EDMC must be reading the environment to begin with somewhere, something like env.get("TMPDIR", env.get("XDG_CACHE_HOME", "/tmp") could perhaps do this semi-hackily with minimal churn (where it is assumed env is a dictionary of the environment). So any users who had explicitly set $TMPDIR and also have whichever XDG directory is chosen (between state and cache) set wouldn't see changes in behaviour.

Expected behavior More or less explained above.

Considered workarounds

Just export TMPDIR=$XDG_CACHE_HOME, though I'd like to avoid this if possible (more variable pollution).

Alternatively launch EDMC with TMPDIR=... ./EDMark... every time.

Additional context

I mostly found it strange how the config and plugin locations properly respected the XDG spec but not the log directory, thus this ask.

ultimatespirit avatar Apr 28 '24 10:04 ultimatespirit

Probably worth moving all logging out of the temp dirs globally.

Rixxan avatar Apr 28 '24 21:04 Rixxan

For this one, I think it makes more sense to make a new dir in app_dir_path (Linux: ~/.local/share/edmarketconnector/logs, Windows: %localappdata%/edmarketconnector/logs) to house this information. This keeps things unified as to where they will be (same place as plugins, fdevid files, etc) rather than scattering information all across the file system.

Rixxan avatar Jun 10 '24 13:06 Rixxan