logging: move to XDG_CACHE_HOME (#13739)

while there is some controversy, stdpath('cache') looks like  a better fit for logs than stdpath('data'): you can remove logs without preventing nvim to work which fits the XDG_CACHE_HOME definition of `user specific non-essential data files`.
This commit is contained in:
Michael Lingelbach
2021-01-13 14:20:21 -08:00
committed by GitHub
parent 77a6049e07
commit ea8756f85d
7 changed files with 29 additions and 19 deletions

View File

@@ -51,7 +51,7 @@ static bool log_try_create(char *fname)
/// Initializes path to log file. Sets $NVIM_LOG_FILE if empty.
///
/// Tries $NVIM_LOG_FILE, or falls back to $XDG_DATA_HOME/nvim/log. Path to log
/// Tries $NVIM_LOG_FILE, or falls back to $XDG_CACHE_HOME/nvim/log. Path to log
/// file is cached, so only the first call has effect, unless first call was not
/// successful. Failed initialization indicates either a bug in expand_env()
/// or both $NVIM_LOG_FILE and $HOME environment variables are undefined.
@@ -70,7 +70,7 @@ static bool log_path_init(void)
|| os_isdir((char_u *)log_file_path)
|| !log_try_create(log_file_path)) {
// Invalid $NVIM_LOG_FILE or failed to expand; fall back to default.
char *defaultpath = stdpaths_user_data_subpath("log", 0, true);
char *defaultpath = stdpaths_user_cache_subpath("log");
size_t len = xstrlcpy(log_file_path, defaultpath, size);
xfree(defaultpath);
// Fall back to .nvimlog