Skip to content

Commit 4a8a29b

Browse files
authored
fix(log): no file made if no cache dir (#392)
On Neovim nightly (currently pre `v0.8`), the log file cannot be created and writen to since the `.cache/nvim` directory is not created. This is fixed by checking that the parent of the outfile does not exist and if it doesn't creating the directory, as mentioned by Conni2461. Fixes: GH-367 Signed-off-by: Filip Dutescu <[email protected]>
1 parent 986ad71 commit 4a8a29b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lua/plenary/log.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ log.new = function(config, standalone)
135135

136136
-- Output to log file
137137
if config.use_file then
138+
local outfile_parent_path = require("plenary.path"):new(outfile):parent()
139+
if not outfile_parent_path:exists() then
140+
outfile_parent_path:mkdir { parent = true }
141+
end
138142
local fp = assert(io.open(outfile, "a"))
139143
local str = string.format("[%-6s%s] %s: %s\n", nameupper, os.date(), lineinfo, msg)
140144
fp:write(str)

0 commit comments

Comments
 (0)