Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions lua/keyevent/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,7 @@ if not ok then
debug = function() end,
info = function() end,
warn = function() end,
error = function(fmt, ...)
local args = { ... }
local message
if type(fmt) == "string" or #args == 0 then
local ok, result = pcall(function()
return string.format(fmt, unpack(args))
end)
if ok then
message = result
end
end
if not message then
local args = { fmt, ... }
local parts = vim.tbl_map(tostring, args)
message = table.concat(parts, " ")
end
error = function(message)
vim.schedule(function()
vim.notify(message, vim.log.levels.ERROR)
end)
Expand Down
5 changes: 2 additions & 3 deletions tests/cases/logger/logger_error/out-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
[KB2][DEBUG][log.lua] log debug 1 two three
[KB2][INFO][log.lua] log info 1 two three
[KB2][WARN][log.lua] log warn 1 two three
[KB2][🟧PRB][log.lua 71] log probe 1 two three
[KB2][🟧PRB][log.lua 56] log probe 1 two three
[KB2][LOG][log.lua] watch
true
[KB2][ERROR][log.lua] log error 1 2 three
[KB2][ERROR][log.lua] <number> 1 <number> 2 <string> three
[KB2][ERROR][log.lua] log error

=== DISPLAY ===

3 changes: 1 addition & 2 deletions tests/cases/logger/logger_error/run.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ lua << EOF
log.watch("LOG", "watch")
print(log.is_debug())
log.assert(true, "OK")
log.error("log error %d %d %s", 1, 2, "three")
log.error(1, 2, "three")
log.error("log error")
EOF

call Snapshot({ 'desc': 'logger' })
5 changes: 2 additions & 3 deletions tests/cases/logger/no_logger_error/out-expected.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

--- CASE 6: logger ---
false
Error detected while processing command line..script /tests/cases/logger/no_logger_error/run.vim[22]..function Snapshot:
Error detected while processing command line..script /tests/cases/logger/no_logger_error/run.vim[21]..function Snapshot:
line 1:
log error 1 2 three
1 2 three
log error
3 changes: 1 addition & 2 deletions tests/cases/logger/no_logger_error/run.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ lua << EOF
log.watch("LOG", "watch")
print(log.is_debug())
log.assert(true, "OK")
log.error("log error %d %d %s", 1, 2, "three")
log.error(1, 2, "three")
log.error("log error")
EOF

call Snapshot({ 'desc': 'logger' })
Loading