Skip to content

Commit ca986ee

Browse files
committed
feat: improve flygrep logger
1 parent 6830996 commit ca986ee

2 files changed

Lines changed: 19 additions & 15 deletions

File tree

lua/flygrep/init.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ local function grep_timer(t)
121121
pcall(vim.api.nvim_buf_del_extmark, prompt_bufid, extns, prompt_count_id)
122122
prompt_count_id = update_result_count()
123123
end
124-
search_jobid = job.start(build_grep_command(), {
124+
local cmd = build_grep_command()
125+
log.debug('cmd is:' .. vim.inspect(cmd))
126+
search_jobid = job.start(cmd, {
125127
on_stdout = function(id, data)
126128
if
127129
id == search_jobid

lua/flygrep/logger.lua

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
local M = {}
2-
local logger
3-
function M.info(msg)
4-
if not logger then
5-
pcall(function()
6-
logger = require('logger').derive('flygrep')
7-
logger.info(msg)
8-
end)
9-
else
10-
logger.info(msg)
11-
end
12-
end
13-
14-
return M
1+
local M = {}
2+
local logger
3+
for _, f in ipairs({ 'info', 'debug', 'warn', 'error' }) do
4+
M[f] = function(msg)
5+
if not logger then
6+
pcall(function()
7+
logger = require('logger').derive('flygrep')
8+
logger[f](msg)
9+
end)
10+
else
11+
logger[f](msg)
12+
end
13+
end
14+
end
15+
16+
return M

0 commit comments

Comments
 (0)