summaryrefslogtreecommitdiffstats
path: root/lua/conform/log.lua
diff options
context:
space:
mode:
authorSteven Arcangeli <506791+stevearc@users.noreply.github.com>2023-08-31 08:54:11 -0700
committerGitHub <noreply@github.com>2023-08-31 08:54:11 -0700
commit3f34f2de48e393b2ee289f2c8fa613c7eabae6d8 (patch)
treee4f6e725d345cdbd07cd3f39f69ee7243592378e /lua/conform/log.lua
parent860bd36663b9b02b42a80c6b7f19642add0551ab (diff)
feat: format() takes an optional callback (#21)
* refactor: replicate lsp.buf.format call * feat: format() takes an optional callback * fix: improper logging * fix: callback returns error if buffer is no longer valid * fix: provide more detailed error message to callback * fix: properly detect task interruption * cleanup: remove unnecessary error code translation * fix: lsp formatting for Neovim 0.9 * doc: add example of async formatting on save * fix: async LSP formatter discards changes if buffer was modified * fix: error code comparison * fix: use the same LSP client filtering logic everywhere * fix: add buffer validity guard checks * fix: add buffer validity guard to LSP formatter * refactor: change the default log level to WARN
Diffstat (limited to 'lua/conform/log.lua')
-rw-r--r--lua/conform/log.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/lua/conform/log.lua b/lua/conform/log.lua
index 753a3c6..3e31fd2 100644
--- a/lua/conform/log.lua
+++ b/lua/conform/log.lua
@@ -5,7 +5,7 @@ vim.tbl_add_reverse_lookup(levels)
local Log = {}
---@type integer
-Log.level = vim.log.levels.ERROR
+Log.level = vim.log.levels.WARN
---@return string
Log.get_logfile = function()
@@ -33,11 +33,17 @@ local function format(level, msg, ...)
end
end
local ok, text = pcall(string.format, msg, vim.F.unpack_len(args))
+ local timestr = vim.fn.strftime("%H:%M:%S")
if ok then
local str_level = levels[level]
- return string.format("%s[%s] %s", vim.fn.strftime("%H:%M:%S"), str_level, text)
+ return string.format("%s[%s] %s", timestr, str_level, text)
else
- return string.format("[ERROR] error formatting log line: '%s' args %s", msg, vim.inspect(args))
+ return string.format(
+ "%s[ERROR] error formatting log line: '%s' args %s",
+ timestr,
+ vim.inspect(msg),
+ vim.inspect(args)
+ )
end
end