mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 17:06:30 +00:00
log.c: warn instead of error on failed stdpath('cache') creation
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
#include "nvim/os/time.h"
|
||||
|
||||
#define LOG_FILE_ENV "NVIM_LOG_FILE"
|
||||
#define LOGERR "E5010: "
|
||||
|
||||
/// Cached location of the expanded log file path decided by log_path_init().
|
||||
static char log_file_path[MAXPATHL + 1] = { 0 };
|
||||
@@ -73,15 +72,10 @@ static bool log_path_init(void)
|
||||
// Make kXDGCacheHome if it does not exist.
|
||||
char *cachehome = get_xdg_home(kXDGCacheHome);
|
||||
char *failed_dir = NULL;
|
||||
bool log_dir_failure = false;
|
||||
if (!os_isdir((char_u *)cachehome)) {
|
||||
int ret;
|
||||
if ((ret = os_mkdir_recurse(cachehome, 0700, &failed_dir)) != 0) {
|
||||
EMSG3(_(LOGERR "Failed to create directory %s "
|
||||
"for writing logs: %s"),
|
||||
failed_dir, os_strerror(ret));
|
||||
}
|
||||
log_dir_failure = (os_mkdir_recurse(cachehome, 0700, &failed_dir) != 0);
|
||||
}
|
||||
XFREE_CLEAR(failed_dir);
|
||||
XFREE_CLEAR(cachehome);
|
||||
// Invalid $NVIM_LOG_FILE or failed to expand; fall back to default.
|
||||
char *defaultpath = stdpaths_user_cache_subpath("log");
|
||||
@@ -97,6 +91,11 @@ static bool log_path_init(void)
|
||||
return false;
|
||||
}
|
||||
os_setenv(LOG_FILE_ENV, log_file_path, true);
|
||||
if (log_dir_failure) {
|
||||
WLOG("Failed to create directory %s for writing logs: %s",
|
||||
failed_dir, os_strerror(log_dir_failure));
|
||||
}
|
||||
XFREE_CLEAR(failed_dir);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -337,4 +336,3 @@ static bool v_do_log_to_file(FILE *log_file, int log_level,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user