enh(core): define a sane default for log file path
Description
Default log file path, when nothing is specified with --log-output
in the user "cache" directory, which is given by $XDG_CACHE_HOME
on Linux or simply $APPDATA
on Windows. As a fallback, the default temporary directory is used. In both cases, the path is suffixed with ./sight/<profile name>
. The final path is also displayed on the console.
VTK.log
andOgre.log
has been taken into account...
Some (light) adjustment and cleanup have also been made in core::tools::Os
to manage "cache" directory and return a std::filesystem::path
instead of a std::string.
this could be a possible breaking change as you may have to call
std::filesystem::path::string()
when callinggetUserConfigDir()
(already fixed in this MR).
getUserDataDir()
name is misleading. Since it returnsXDG_CONFIG_HOME
it should be calledgetUserConfigDir()
. It was hard to not change this in this MR for me, so it was done....
And last but not least, a small "fix" in PreferencesTest
to clean correctly the user config directory after the test pass. I come through it while changing the getUserDataDir()
returned type to std::filesystem::path
.
Closes #865 (closed)
How to test it?
- Launch an application, as a normal user, without
--log-output
. The log file should be created in~/.cache/sight/<profile_name>/sight.<counter>.log
on Linux and something likeC:\Users\<user>\AppData\Roaming\sight\<profile_name>\sight.<counter>.log
on Windows. - Same as root (Linux) or Administrator (Windows). On Linux, the home change and the path should start with
/root/...
and should be unchanged on Windows. - Try the same, but with
--log-output
. Ensure that--log-output <path>
works as expected.