From abfe6c9ef7f4bd41c1306f3c70ead00e4afaa736 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 18 Feb 2026 11:58:34 -0500 Subject: [PATCH] feat(logging): rename ".nvimlog" => "nvim.log" #37935 - Rename ".nvimlog" to "nvim.log" - doesn't need to be "hidden"/dotfile - ".log" extension helps with filetype detection - Also rename "nvim/log" => "nvim/nvim.log" --- .github/workflows/test.yml | 3 ++- .gitignore | 3 --- cmake/RunTests.cmake | 2 +- runtime/doc/dev_test.txt | 6 +++++- runtime/doc/dev_tools.txt | 2 +- runtime/doc/starting.txt | 10 +++++----- src/man/nvim.1 | 2 +- src/nvim/log.c | 8 ++++---- test/functional/options/defaults_spec.lua | 8 ++++---- test/testutil.lua | 23 ++++++++++++----------- 10 files changed, 35 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a9b7e3b23..25b5fa5899 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ env: BUILD_DIR: ${{ github.workspace }}/build INSTALL_PREFIX: ${{ github.workspace }}/nvim-install LOG_DIR: ${{ github.workspace }}/build/log - NVIM_LOG_FILE: ${{ github.workspace }}/build/.nvimlog + NVIM_LOG_FILE: ${{ github.workspace }}/build/nvim.log TSAN_OPTIONS: log_path=${{ github.workspace }}/build/log/tsan VALGRIND_LOG: ${{ github.workspace }}/build/log/valgrind-%p.log # TEST_FILE: test/functional/core/startup_spec.lua @@ -176,6 +176,7 @@ jobs: TEST_TIMEOUT: 600 run: | set +e + # `-k 0` tells ninja to continue running all targets even if some fail. cmake --build build --target functionaltest_parallel -j 2 -- -k 0 exit_code="$?" cmake --build build --target functionaltest_summary diff --git a/.gitignore b/.gitignore index 9e5a225ba2..9703749045 100644 --- a/.gitignore +++ b/.gitignore @@ -33,9 +33,6 @@ compile_commands.json /src/nvim/po/vim.pot /src/nvim/po/*.ck -# Generated by tests with $NVIM_LOG_FILE set. -/.nvimlog - # Generated by scripts/vim-patch.sh /.vim-src *.rej diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake index 48876c07c8..951afcf747 100644 --- a/cmake/RunTests.cmake +++ b/cmake/RunTests.cmake @@ -27,7 +27,7 @@ unset(ENV{TMUX}) # Nvim TUI shouldn't think it's running in tmux. #34173 set(ENV{CIRRUS_CI} ${CIRRUS_CI}) if(NOT DEFINED ENV{NVIM_LOG_FILE}) - set(ENV{NVIM_LOG_FILE} ${BUILD_DIR}/.nvimlog) + set(ENV{NVIM_LOG_FILE} ${BUILD_DIR}/nvim.log) endif() set(ENV{NVIM_LOG_FILE} "$ENV{NVIM_LOG_FILE}${TEST_SUFFIX}") diff --git a/runtime/doc/dev_test.txt b/runtime/doc/dev_test.txt index 7bcfdbcc05..72bb398006 100644 --- a/runtime/doc/dev_test.txt +++ b/runtime/doc/dev_test.txt @@ -38,7 +38,7 @@ see also |lua-guide|. Use any existing test as a template to start writing new tests, or see |dev-quickstart|. Tests are run by the `/cmake/RunTests.cmake` script using `busted` (a Lua test-runner). -For some failures, `.nvimlog` (or `$NVIM_LOG_FILE`) may provide insight. +For some failures, `./build/nvim.log` (or `$NVIM_LOG_FILE`) may provide insight. Depending on the presence of binaries (e.g., `xclip`) some tests will be skipped. @@ -80,6 +80,10 @@ To run only _unit_ tests: > To run only _functional_ tests: > make functionaltest +To run functional tests in parallel (used in CI): > + cmake --build build --target functionaltest_parallel -j2 + cmake --build build --target functionaltest_summary + LEGACY TESTS diff --git a/runtime/doc/dev_tools.txt b/runtime/doc/dev_tools.txt index 9d79caa892..5234ce0fc5 100644 --- a/runtime/doc/dev_tools.txt +++ b/runtime/doc/dev_tools.txt @@ -74,7 +74,7 @@ alternate file (e.g. stderr) use `LOG_CALLSTACK_TO_FILE(FILE*)`. Requires Many log messages have a shared prefix, such as "UI" or "RPC". Use the shell to filter the log, e.g. at DEBUG level you might want to exclude UI messages: > - tail -F ~/.local/state/nvim/log | cat -v | stdbuf -o0 grep -v UI | stdbuf -o0 tee -a log + tail -F ~/.local/state/nvim/nvim.log | cat -v | stdbuf -o0 grep -v UI | stdbuf -o0 tee -a log ============================================================================== diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 0113a90e73..d8f209452f 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1411,9 +1411,9 @@ CACHE DIRECTORY (DEFAULT) ~ Windows: ~/AppData/Local/Temp ~/AppData/Local/Temp/nvim-data LOG FILE (DEFAULT) ~ - `$NVIM_LOG_FILE` Nvim: stdpath("log")/log - Unix: ~/.local/state/nvim ~/.local/state/nvim/log - Windows: ~/AppData/Local/nvim-data ~/AppData/Local/nvim-data/log + `$NVIM_LOG_FILE` Nvim: stdpath("log")/nvim.log + Unix: ~/.local/state/nvim ~/.local/state/nvim/nvim.log + Windows: ~/AppData/Local/nvim-data ~/AppData/Local/nvim-data/nvim.log Note that stdpath("log") is currently an alias for stdpath("state"). @@ -1453,8 +1453,8 @@ LOG FILE *log* *$NVIM_LOG_FILE* *E5430* Besides 'debug' and 'verbose', Nvim keeps a general log file for internal debugging, plugins and RPC clients. > :echo $NVIM_LOG_FILE -By default, the file is located at stdpath("log")/log ($XDG_STATE_HOME/nvim/log) -unless that path is inaccessible or if $NVIM_LOG_FILE was set before |startup|. +Default location is stdpath("log")/log ($XDG_STATE_HOME/nvim/nvim.log) unless +that path is inaccessible or $NVIM_LOG_FILE was set before |startup|. vim:noet:tw=78:ts=8:ft=help:norl: diff --git a/src/man/nvim.1 b/src/man/nvim.1 index 623018d50d..846afd613f 100644 --- a/src/man/nvim.1 +++ b/src/man/nvim.1 @@ -351,7 +351,7 @@ Defaults to .Ic ":help $NVIM_APPNAME" .It Ev NVIM_LOG_FILE Low-level log file, usually found at -.Pa ~/.local/state/nvim/log . +.Pa ~/.local/state/nvim/nvim.log . .Ic ":help $NVIM_LOG_FILE" .It Ev VIM Used to locate user files, such as init.vim. diff --git a/src/nvim/log.c b/src/nvim/log.c index d3dd2cb7b6..0f9101832d 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -58,7 +58,7 @@ static bool log_try_create(char *fname) /// Initializes the log file path and sets $NVIM_LOG_FILE if empty. /// -/// Tries $NVIM_LOG_FILE, or falls back to $XDG_STATE_HOME/nvim/log. Failed +/// Tries $NVIM_LOG_FILE, or falls back to $XDG_STATE_HOME/nvim/nvim.log. Failed /// initialization indicates either a bug in expand_env() or both $NVIM_LOG_FILE /// and $HOME environment variables are undefined. static void log_path_init(void) @@ -78,12 +78,12 @@ static void log_path_init(void) } XFREE_CLEAR(loghome); // Invalid $NVIM_LOG_FILE or failed to expand; fall back to default. - char *defaultpath = stdpaths_user_state_subpath("log", 0, true); + char *defaultpath = stdpaths_user_state_subpath("nvim.log", 0, true); size_t len = xstrlcpy(log_file_path, defaultpath, size); xfree(defaultpath); - // Fall back to .nvimlog + // Fall back to $CWD/nvim.log if (len >= size || !log_try_create(log_file_path)) { - len = xstrlcpy(log_file_path, ".nvimlog", size); + len = xstrlcpy(log_file_path, "nvim.log", size); } // Fall back to stderr if (len >= size || !log_try_create(log_file_path)) { diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index e2bc64c210..30bd8598c5 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -252,7 +252,7 @@ describe('startup defaults', function() eq('Xtest-logpath', eval('$NVIM_LOG_FILE')) end) - it('defaults to stdpath("log")/log if empty', function() + it('defaults to stdpath("log")/nvim.log if empty', function() eq(true, mkdir(xdgdir) and mkdir(xdgstatedir)) clear({ env = { @@ -260,10 +260,10 @@ describe('startup defaults', function() NVIM_LOG_FILE = '', -- Empty is invalid. }, }) - eq(xdgstatedir .. '/log', t.fix_slashes(eval('$NVIM_LOG_FILE'))) + eq(xdgstatedir .. '/nvim.log', t.fix_slashes(eval('$NVIM_LOG_FILE'))) end) - it('defaults to stdpath("log")/log if invalid', function() + it('defaults to stdpath("log")/nvim.log if invalid', function() eq(true, mkdir(xdgdir) and mkdir(xdgstatedir)) clear({ env = { @@ -271,7 +271,7 @@ describe('startup defaults', function() NVIM_LOG_FILE = '.', -- Any directory is invalid. }, }) - eq(xdgstatedir .. '/log', t.fix_slashes(eval('$NVIM_LOG_FILE'))) + eq(xdgstatedir .. '/nvim.log', t.fix_slashes(eval('$NVIM_LOG_FILE'))) -- Avoid "failed to open $NVIM_LOG_FILE" noise in test output. expect_exit(command, 'qall!') end) diff --git a/test/testutil.lua b/test/testutil.lua index 7709ac464f..bffd9763b5 100644 --- a/test/testutil.lua +++ b/test/testutil.lua @@ -73,8 +73,8 @@ end --- @param fn function --- @return any function M.retry(max, max_ms, fn) - luaassert(max == nil or max > 0) - luaassert(max_ms == nil or max_ms > 0) + assert(max == nil or max > 0) + assert(max_ms == nil or max_ms > 0) local tries = 1 local timeout = (max_ms and max_ms or 10000) local start_time = uv.now() @@ -112,12 +112,12 @@ end --- @param expected (any) description of expected result --- @param actual (any) description of actual result function M.ok(cond, expected, actual) - luaassert( + assert( (not expected and not actual) or (expected and actual), 'if "expected" is given, "actual" is also required' ) local msg = expected and ('expected %s, got: %s'):format(expected, tostring(actual)) or nil - return luaassert(cond, msg) + return assert(cond, msg) end local function epicfail(state, arguments, _) @@ -151,8 +151,8 @@ end ---@param nrlines? (number) Search up to this many log lines (default 10) ---@param inverse? (boolean) Assert that the pattern does NOT match. function M.assert_log(pat, logfile, nrlines, inverse) - logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog' - luaassert(logfile ~= nil, 'no logfile') + logfile = logfile or os.getenv('NVIM_LOG_FILE') or 'nvim.log' + assert(logfile ~= nil, 'no logfile') nrlines = nrlines or 10 M.retry(nil, 1000, function() @@ -161,7 +161,7 @@ function M.assert_log(pat, logfile, nrlines, inverse) local ismatch = not not text:match(pat) if (ismatch and inverse) or not (ismatch or inverse) then local msg = string.format( - 'Pattern %s %sfound in log (last %d lines): %s:\n%s', + 'Pattern %s %sfound in log (last %d lines): %q:\n%s', vim.inspect(pat), (inverse and '' or 'not '), nrlines, @@ -187,7 +187,7 @@ end --- @param ... any --- @return boolean, any function M.pcall(fn, ...) - luaassert(type(fn) == 'function') + assert(type(fn) == 'function') local status, rv = pcall(fn, ...) if status then return status, rv @@ -236,7 +236,7 @@ end --- @param fn function --- @return string function M.pcall_err_withfile(fn, ...) - luaassert(type(fn) == 'function') + assert(type(fn) == 'function') local status, rv = M.pcall(fn, ...) if status == true then error('expected failure, but got success') @@ -785,7 +785,7 @@ end --- @return boolean function M.is_ci(name) local any = (name == nil) - luaassert(any or name == 'github' or name == 'cirrus') + assert(any or name == 'github' or name == 'cirrus') local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS')) local cirrus = ((any or name == 'cirrus') and nil ~= os.getenv('CIRRUS_CI')) return gh or cirrus @@ -794,7 +794,8 @@ end -- Gets the (tail) contents of `logfile`. -- Also moves the file to "${NVIM_LOG_FILE}.displayed" on CI environments. function M.read_nvim_log(logfile, ci_rename) - logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog' + logfile = logfile or os.getenv('NVIM_LOG_FILE') or 'nvim.log' + assert(uv.fs_stat(logfile), ('logfile not found: %q'):format(logfile)) local is_ci = M.is_ci() local keep = is_ci and 100 or 10 local lines = M.read_file_list(logfile, -keep) or {}