feat: silence debug msg (#636)
This commit is contained in:
parent
0d90c047ef
commit
22243bc316
@ -73,9 +73,9 @@ M.build = function(opts)
|
|||||||
local output = stdout
|
local output = stdout
|
||||||
if #output == 0 then
|
if #output == 0 then
|
||||||
table.insert(output, "")
|
table.insert(output, "")
|
||||||
Utils.debug(output)
|
Utils.debug("build output:", output)
|
||||||
else
|
else
|
||||||
Utils.debug(stderr)
|
Utils.debug("build error:", stderr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -84,8 +84,7 @@ M.stream = function(opts)
|
|||||||
:filter(function(k) return k ~= "" end)
|
:filter(function(k) return k ~= "" end)
|
||||||
:totable()
|
:totable()
|
||||||
|
|
||||||
Utils.debug(user_prompts)
|
Utils.debug("user prompts:", user_prompts)
|
||||||
-- print(user_prompts[1])
|
|
||||||
|
|
||||||
---@type AvantePromptOptions
|
---@type AvantePromptOptions
|
||||||
local code_opts = {
|
local code_opts = {
|
||||||
@ -102,7 +101,7 @@ M.stream = function(opts)
|
|||||||
---@type AvanteCurlOutput
|
---@type AvanteCurlOutput
|
||||||
local spec = Provider.parse_curl_args(Provider, code_opts)
|
local spec = Provider.parse_curl_args(Provider, code_opts)
|
||||||
|
|
||||||
Utils.debug(spec)
|
Utils.debug("curl spec:", spec)
|
||||||
|
|
||||||
---@param line string
|
---@param line string
|
||||||
local function parse_stream_data(line)
|
local function parse_stream_data(line)
|
||||||
@ -182,7 +181,7 @@ M.stream = function(opts)
|
|||||||
-- Error: cannot resume dead coroutine
|
-- Error: cannot resume dead coroutine
|
||||||
if active_job then
|
if active_job then
|
||||||
xpcall(function() active_job:shutdown() end, function(err) return err end)
|
xpcall(function() active_job:shutdown() end, function(err) return err end)
|
||||||
Utils.debug("LLM request cancelled", { title = "Avante" })
|
Utils.debug("LLM request cancelled")
|
||||||
active_job = nil
|
active_job = nil
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -81,7 +81,7 @@ function Suggestion:suggest()
|
|||||||
Utils.error("Error while suggesting: " .. vim.inspect(err), { once = true, title = "Avante" })
|
Utils.error("Error while suggesting: " .. vim.inspect(err), { once = true, title = "Avante" })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
Utils.debug("full_response: " .. vim.inspect(full_response))
|
Utils.debug("full_response:", full_response)
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
local cursor_row, cursor_col = Utils.get_cursor_pos()
|
local cursor_row, cursor_col = Utils.get_cursor_pos()
|
||||||
if cursor_row ~= doc.position.row or cursor_col ~= doc.position.col then return end
|
if cursor_row ~= doc.position.row or cursor_col ~= doc.position.col then return end
|
||||||
|
@ -123,7 +123,7 @@ M.safe_keymap_set = function(mode, lhs, rhs, opts)
|
|||||||
|
|
||||||
ok, H = pcall(require, "lazy.core.handler")
|
ok, H = pcall(require, "lazy.core.handler")
|
||||||
if not ok then
|
if not ok then
|
||||||
M.debug("lazy.nvim is not available. Avante will use vim.keymap.set", { once = true })
|
M.debug("lazy.nvim is not available. Avante will use vim.keymap.set")
|
||||||
vim.keymap.set(mode, lhs, rhs, opts)
|
vim.keymap.set(mode, lhs, rhs, opts)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -324,18 +324,21 @@ function M.warn(msg, opts)
|
|||||||
M.notify(msg, opts)
|
M.notify(msg, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param msg string|table
|
function M.debug(...)
|
||||||
---@param opts? LazyNotifyOpts
|
|
||||||
function M.debug(msg, opts)
|
|
||||||
if not require("avante.config").options.debug then return end
|
if not require("avante.config").options.debug then return end
|
||||||
opts = opts or {}
|
|
||||||
if opts.title then opts.title = "avante.nvim: " .. opts.title end
|
local args = { ... }
|
||||||
if type(msg) == "string" then
|
if #args == 0 then return end
|
||||||
M.notify(msg, opts)
|
local timestamp = os.date("%Y-%m-%d %H:%M:%S")
|
||||||
else
|
local formated_args = { "[" .. timestamp .. "] [AVANTE] [DEBUG]" }
|
||||||
opts.lang = "lua"
|
for _, arg in ipairs(args) do
|
||||||
M.notify(vim.inspect(msg), opts)
|
if type(arg) == "string" then
|
||||||
|
table.insert(formated_args, arg)
|
||||||
|
else
|
||||||
|
table.insert(formated_args, vim.inspect(arg))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
print(unpack(formated_args))
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.tbl_indexof(tbl, value)
|
function M.tbl_indexof(tbl, value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user