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

Commit

Permalink
fix(logger): Fix when stdpath('data') doesn't exist @dwarfmaster #364
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarfmaster authored Jul 29, 2022
1 parent 5a41c6a commit 6d2e9c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if vim.fn.has("nvim-0.6.0") ~= 1 then
return
end

-- Makes sure ~/.local/share/nvim exists, to prevent problems with logging
vim.fn.mkdir(vim.fn.stdpath("data"), 'p')

-- Add ~/.local/share to runtimepath early, such that
-- neovim autoloads plugin/packer_compiled.lua along with vimscript,
-- before we start using the plugins it lazy-loads.
Expand Down
10 changes: 7 additions & 3 deletions lua/doom/utils/logging.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ log.new = function(config, standalone)
-- Output to log file
if config.use_file then
local fp = io.open(outfile, "a")
local str = string.format("[%-6s%s] %s: %s\n", nameupper, os.date(), lineinfo, msg)
fp:write(str)
fp:close()
if not fp then
vim.cmd(string.format([[echom "Couldn't open log file [%s]"]], outfile))
else
local str = string.format("[%-6s%s] %s: %s\n", nameupper, os.date(), lineinfo, msg)
fp:write(str)
fp:close()
end
end
end

Expand Down

0 comments on commit 6d2e9c9

Please sign in to comment.