-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(logger): adapt to new changes upstream #3695
Conversation
f5d4a97
to
16c9788
Compare
Thanks for the heads-up :) |
Add a flag for disabling vim.notify logging as notification (to discuss)
16c9788
to
cb4012f
Compare
Something like this is needed, otherwise there are errors after updating, we can't be sure that the structlog version is always the one specified in the snapshot diff --git a/lua/lvim/core/log.lua b/lua/lvim/core/log.lua
index 2602e64..27adc2a 100644
--- a/lua/lvim/core/log.lua
+++ b/lua/lvim/core/log.lua
@@ -13,21 +13,27 @@ local notify_opts = {}
local log_notify_as_notification = false
function Log:set_level(level)
- local logger_ok, logger = pcall(function()
- return require("structlog").get_logger "lvim"
- end)
- local log_level = Log.levels[level:upper()]
- if logger_ok and logger and log_level then
- for _, pipeline in ipairs(logger.pipelines) do
- pipeline.level = log_level
- end
- end
+ if
+ not pcall(function()
+ local logger_ok, logger = pcall(function()
+ return require("structlog").get_logger "lvim"
+ end)
+ local log_level = Log.levels[level:upper()]
+ if logger_ok and logger and log_level then
+ for _, pipeline in ipairs(logger.pipelines) do
+ pipeline.level = log_level
+ end
+ end
- local packer_ok, _ = xpcall(function()
- require("packer.log").cfg { log = { level = level } }
- end, debug.traceback)
- if not packer_ok then
- vim.notify_once("Unable to set packer's log level to " .. level)
+ local packer_ok, _ = xpcall(function()
+ require("packer.log").cfg { log = { level = level } }
+ end, debug.traceback)
+ if not packer_ok then
+ vim.notify_once("Unable to set packer's log level to " .. level)
+ end
+ end)
+ then
+ vim.cmd "echo 'structlog version too old, run `:Lazy sync`'"
end
end
@@ -130,11 +136,17 @@ end
---@param msg any
---@param event any
function Log:add_entry(level, msg, event)
- local logger = self:get_logger()
- if not logger then
- return
+ if
+ not pcall(function()
+ local logger = self:get_logger()
+ if not logger then
+ return
+ end
+ logger:log(level, vim.inspect(msg), event)
+ end)
+ then
+ vim.cmd "echo 'structlog version too old, run `:Lazy sync`'"
end
- logger:log(level, vim.inspect(msg), event)
end
---Retrieves the handle of the logger object |
Indeed, it is not something I thought about, since when testing it I removed the directory manually. Could it help if structlog would expose its version number ( On another topic, I added the |
With this we could add a mechanism update structlog on startup if the version is too old, and then remove it on next release, but I'm not sure it it's worth it, updates between releases remove the plugins directory anyway so it's just for master users
configure_notifications isn't called anywhere currently, I wasn't on the team when it was so I'm not the best person to answer this, but personally I think vim.notify messages should be shown to the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
I had to go into
|
that's what I was talking about here #3695 (comment), |
* upstream/master: refactor!: remove `%` and `$` autopairs rules (LunarVim#3759) chore: bump plugins version (LunarVim#3761) feat: add crystal filetype (LunarVim#3762) fix(lsp): info diagnostic icon not showing (LunarVim#3756) fix(logger): fix errors with older structlog versions (LunarVim#3755) chore: bump plugins version (LunarVim#3679) refactor(logger): adapt to new changes upstream (LunarVim#3695)
Description
Refactor structlog usage for future 0.2 release
How Has This Been Tested?
Related work
Tastyep/structlog.nvim#6