Skip to content

Commit

Permalink
feat: option to output logging to the qflist (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
TC72 authored Sep 30, 2021
1 parent 8c6cc07 commit 6bb0e09
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lua/plenary/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ local default_config = {
-- Should write to a file
use_file = true,

-- Should write to the quickfix list
use_quickfix = false,

-- Any messages above this level will be logged.
level = p_debug and "debug" or "info",

Expand Down Expand Up @@ -137,6 +140,19 @@ log.new = function(config, standalone)
fp:write(str)
fp:close()
end

-- Output to quickfix
if config.use_quickfix then
local formatted_msg = string.format("[%s] %s", nameupper, msg)
local qf_entry = {
-- remove the @ getinfo adds to the file path
filename = info.source:sub(2),
lnum = info.currentline,
col = 1,
text = formatted_msg,
}
vim.fn.setqflist({ qf_entry }, "a")
end
end

for i, x in ipairs(config.modes) do
Expand Down

0 comments on commit 6bb0e09

Please sign in to comment.