feat: rename
This commit is contained in:
parent
e1d7abf58e
commit
942438f817
21 changed files with 660 additions and 305 deletions
35
lua/preview/log.lua
Normal file
35
lua/preview/log.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
local M = {}
|
||||
|
||||
local enabled = false
|
||||
local log_file = nil
|
||||
|
||||
---@param val boolean|string
|
||||
function M.set_enabled(val)
|
||||
if type(val) == 'string' then
|
||||
enabled = true
|
||||
log_file = val
|
||||
else
|
||||
enabled = val
|
||||
log_file = nil
|
||||
end
|
||||
end
|
||||
|
||||
---@param msg string
|
||||
---@param ... any
|
||||
function M.dbg(msg, ...)
|
||||
if not enabled then
|
||||
return
|
||||
end
|
||||
local formatted = '[preview.nvim]: ' .. string.format(msg, ...)
|
||||
if log_file then
|
||||
local f = io.open(log_file, 'a')
|
||||
if f then
|
||||
f:write(string.format('%.6fs', vim.uv.hrtime() / 1e9) .. ' ' .. formatted .. '\n')
|
||||
f:close()
|
||||
end
|
||||
else
|
||||
vim.notify(formatted, vim.log.levels.DEBUG)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue