From b98395770d411a1ddde39694bc49dca137d77252 Mon Sep 17 00:00:00 2001 From: OGAWA Keiji <70509917+kibi2@users.noreply.github.com> Date: Sat, 10 Oct 2026 15:31:40 +0900 Subject: [PATCH] refactor: simplify log.error arguments --- lua/keyevent/log.lua | 17 +---------------- .../cases/logger/logger_error/out-expected.txt | 5 ++--- tests/cases/logger/logger_error/run.vim | 3 +-- .../logger/no_logger_error/out-expected.txt | 5 ++--- tests/cases/logger/no_logger_error/run.vim | 3 +-- 5 files changed, 7 insertions(+), 26 deletions(-) diff --git a/lua/keyevent/log.lua b/lua/keyevent/log.lua index 9e009a4..8d93784 100644 --- a/lua/keyevent/log.lua +++ b/lua/keyevent/log.lua @@ -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) diff --git a/tests/cases/logger/logger_error/out-expected.txt b/tests/cases/logger/logger_error/out-expected.txt index c5074ad..b58db5f 100644 --- a/tests/cases/logger/logger_error/out-expected.txt +++ b/tests/cases/logger/logger_error/out-expected.txt @@ -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] 1 2 three +[KB2][ERROR][log.lua] log error === DISPLAY === diff --git a/tests/cases/logger/logger_error/run.vim b/tests/cases/logger/logger_error/run.vim index 5a7f3ae..f5fe8bb 100644 --- a/tests/cases/logger/logger_error/run.vim +++ b/tests/cases/logger/logger_error/run.vim @@ -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' }) diff --git a/tests/cases/logger/no_logger_error/out-expected.txt b/tests/cases/logger/no_logger_error/out-expected.txt index 0b39f6b..147c07c 100644 --- a/tests/cases/logger/no_logger_error/out-expected.txt +++ b/tests/cases/logger/no_logger_error/out-expected.txt @@ -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 \ No newline at end of file +log error \ No newline at end of file diff --git a/tests/cases/logger/no_logger_error/run.vim b/tests/cases/logger/no_logger_error/run.vim index c027ec1..e1879b5 100644 --- a/tests/cases/logger/no_logger_error/run.vim +++ b/tests/cases/logger/no_logger_error/run.vim @@ -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' })