Skip to content

Commit 22b52dd

Browse files
authored
log_init: call log_path_init (neovim#11501)
This has to be done after `init_homedir` for XDG default and `set_init_1` for lookup from env, which could be done earlier likely (to help with neovim#10937), but this keeps it in sync with Vim. Fixes neovim#11499.
1 parent 56be9fb commit 22b52dd

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

src/nvim/log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static bool log_path_init(void)
9393
void log_init(void)
9494
{
9595
uv_mutex_init(&mutex);
96+
log_path_init();
9697
}
9798

9899
void log_lock(void)

src/nvim/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ static const char *err_extra_cmd =
144144

145145
void event_init(void)
146146
{
147-
log_init();
148147
loop_init(&main_loop, NULL);
149148
resize_events = multiqueue_new_child(main_loop.events);
150149

@@ -220,6 +219,7 @@ void early_init(void)
220219
// First find out the home directory, needed to expand "~" in options.
221220
init_homedir(); // find real value of $HOME
222221
set_init_1();
222+
log_init();
223223
TIME_MSG("inits 1");
224224

225225
set_lang_var(); // set v:lang and v:ctype

test/functional/options/defaults_spec.lua

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ describe('startup defaults', function()
224224
XDG_DATA_HOME=xdgdir,
225225
NVIM_LOG_FILE='', -- Empty is invalid.
226226
}})
227-
-- server_start() calls ELOG, which tickles log_path_init().
228-
pcall(command, 'call serverstart(serverlist()[0])')
229-
230227
eq(xdgdir..'/'..datasubdir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/'))
231228
end)
232229
it('defaults to stdpath("data")/log if invalid', function()
@@ -235,19 +232,13 @@ describe('startup defaults', function()
235232
XDG_DATA_HOME=xdgdir,
236233
NVIM_LOG_FILE='.', -- Any directory is invalid.
237234
}})
238-
-- server_start() calls ELOG, which tickles log_path_init().
239-
pcall(command, 'call serverstart(serverlist()[0])')
240-
241235
eq(xdgdir..'/'..datasubdir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/'))
242236
end)
243237
it('defaults to .nvimlog if stdpath("data") is invalid', function()
244238
clear({env={
245239
XDG_DATA_HOME='Xtest-missing-xdg-dir',
246240
NVIM_LOG_FILE='.', -- Any directory is invalid.
247241
}})
248-
-- server_start() calls ELOG, which tickles log_path_init().
249-
pcall(command, 'call serverstart(serverlist()[0])')
250-
251242
eq('.nvimlog', eval('$NVIM_LOG_FILE'))
252243
end)
253244
end)

0 commit comments

Comments
 (0)