1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:40:06 +08:00

feat(logger): add millisecond info

This commit is contained in:
Shidong Wang 2021-11-13 21:22:47 +08:00
parent 6ce3947d48
commit ae098bab41
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848

View File

@ -22,6 +22,7 @@ local M = {
-- 2 : log warn, error messages
-- 3 : log error messages
M.levels = {'Info ', 'Warn ', 'Error', 'Debug'}
M.clock = fn.reltime()
function M.set_silent(sl)
M.silent = sl
@ -40,7 +41,12 @@ function M._build_msg(msg, l)
local time = fn.strftime('%H:%M:%S')
-- error(string.format("Tried to call API function with vim.fn: use vim.api.%s instead", key))
-- local log = '[ ' .. M.name .. ' ] [' .. time .. '] [ ' .. M.levels[l] .. '] ' .. msg
local log = string.format('[ %s ] [%s] [ %s ] %s', M.name, time, M.levels[l], msg)
local log = string.format('[ %s ] [%s] [%00.3f] [ %s ] %s',
M.name,
time,
fn.reltimefloat(fn.reltime(M.clock)),
M.levels[l],
msg)
return log
end