zhangkun9038@dingtalk.com 07abe12f54 add request log
2025-02-09 22:17:25 +08:00

31 lines
498 B
Lua

local M = {}
local log_file = vim.fn.stdpath("cache") .. "/avante_requests.log"
function M.log_request(url, headers, body)
local timestamp = os.date("%Y-%m-%d %H:%M:%S")
local log_entry = string.format(
[[
[%s] Request Details:
URL: %s
Headers:
%s
Body:
%s
]],
timestamp,
url,
vim.inspect(headers),
vim.inspect(body)
)
-- Append to log file
local file = io.open(log_file, "a")
if file then
file:write(log_entry .. "\n\n")
file:close()
end
end
return M