fix(log): improve logging
This commit is contained in:
parent
62af1965f8
commit
a925686a17
10 changed files with 144 additions and 225 deletions
|
|
@ -7,15 +7,20 @@ local logger = require('cp.log')
|
|||
local platforms = constants.PLATFORMS
|
||||
|
||||
function M.handle_cache_command(cmd)
|
||||
cmd.platform = cmd.platform:lower()
|
||||
if cmd.subcommand == 'clear' then
|
||||
cache.load()
|
||||
if cmd.platform then
|
||||
if vim.tbl_contains(platforms, cmd.platform) then
|
||||
cache.clear_platform(cmd.platform)
|
||||
logger.log(('cleared cache for %s'):format(cmd.platform), vim.log.levels.INFO, true)
|
||||
logger.log(
|
||||
('Cache cleared for platform %s'):format(cmd.platform),
|
||||
vim.log.levels.INFO,
|
||||
true
|
||||
)
|
||||
else
|
||||
logger.log(
|
||||
('unknown platform: %s. Available: %s'):format(
|
||||
("Unknown platform: '%s'. Available: %s"):format(
|
||||
cmd.platform,
|
||||
table.concat(platforms, ', ')
|
||||
),
|
||||
|
|
@ -24,7 +29,7 @@ function M.handle_cache_command(cmd)
|
|||
end
|
||||
else
|
||||
cache.clear_all()
|
||||
logger.log('cleared all cache', vim.log.levels.INFO, true)
|
||||
logger.log('Cache cleared', vim.log.levels.INFO, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ function M.handle_pick_action()
|
|||
|
||||
if not config.picker then
|
||||
logger.log(
|
||||
'No picker configured. Set picker = "telescope" or picker = "fzf-lua" in config',
|
||||
'No picker configured. Set picker = "{telescope,fzf-lua}" in your config.',
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
return
|
||||
|
|
@ -20,14 +20,14 @@ function M.handle_pick_action()
|
|||
local ok = pcall(require, 'telescope')
|
||||
if not ok then
|
||||
logger.log(
|
||||
'Telescope not available. Install telescope.nvim or change picker config',
|
||||
'telescope.nvim is not available. Install telescope.nvim xor change your picker config.',
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
return
|
||||
end
|
||||
local ok_cp, telescope_picker = pcall(require, 'cp.pickers.telescope')
|
||||
if not ok_cp then
|
||||
logger.log('Failed to load telescope integration', vim.log.levels.ERROR)
|
||||
logger.log('Failed to load telescope integration.', vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -36,14 +36,14 @@ function M.handle_pick_action()
|
|||
local ok, _ = pcall(require, 'fzf-lua')
|
||||
if not ok then
|
||||
logger.log(
|
||||
'fzf-lua not available. Install fzf-lua or change picker config',
|
||||
'fzf-lua is not available. Install fzf-lua xor change your picker config',
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
return
|
||||
end
|
||||
local ok_cp, fzf_picker = pcall(require, 'cp.pickers.fzf_lua')
|
||||
if not ok_cp then
|
||||
logger.log('Failed to load fzf-lua integration', vim.log.levels.ERROR)
|
||||
logger.log('Failed to load fzf-lua integration.', vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue