Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit 6d2e9c9

Browse files
authored
fix(logger): Fix when stdpath('data') doesn't exist @dwarfmaster #364
1 parent 5a41c6a commit 6d2e9c9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ if vim.fn.has("nvim-0.6.0") ~= 1 then
77
return
88
end
99

10+
-- Makes sure ~/.local/share/nvim exists, to prevent problems with logging
11+
vim.fn.mkdir(vim.fn.stdpath("data"), 'p')
12+
1013
-- Add ~/.local/share to runtimepath early, such that
1114
-- neovim autoloads plugin/packer_compiled.lua along with vimscript,
1215
-- before we start using the plugins it lazy-loads.

lua/doom/utils/logging.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ log.new = function(config, standalone)
111111
-- Output to log file
112112
if config.use_file then
113113
local fp = io.open(outfile, "a")
114-
local str = string.format("[%-6s%s] %s: %s\n", nameupper, os.date(), lineinfo, msg)
115-
fp:write(str)
116-
fp:close()
114+
if not fp then
115+
vim.cmd(string.format([[echom "Couldn't open log file [%s]"]], outfile))
116+
else
117+
local str = string.format("[%-6s%s] %s: %s\n", nameupper, os.date(), lineinfo, msg)
118+
fp:write(str)
119+
fp:close()
120+
end
117121
end
118122
end
119123

0 commit comments

Comments
 (0)