浏览代码

fix(logger): set console logging to sync (#3379)

LostNeophyte 2 年之前
父节点
当前提交
060116eff0
共有 3 个文件被更改,包括 12 次插入7 次删除
  1. 9 5
      lua/lvim/bootstrap.lua
  2. 1 1
      lua/lvim/config/defaults.lua
  3. 2 1
      lua/lvim/core/log.lua

+ 9 - 5
lua/lvim/bootstrap.lua

@@ -112,11 +112,15 @@ end
 ---Update LunarVim
 ---Update LunarVim
 ---pulls the latest changes from github and, resets the startup cache
 ---pulls the latest changes from github and, resets the startup cache
 function M:update()
 function M:update()
-  reload("lvim.utils.hooks").run_pre_update()
-  local ret = reload("lvim.utils.git").update_base_lvim()
-  if ret then
-    reload("lvim.utils.hooks").run_post_update()
-  end
+  require("lvim.core.log"):info "Trying to update LunarVim..."
+
+  vim.schedule(function()
+    reload("lvim.utils.hooks").run_pre_update()
+    local ret = reload("lvim.utils.git").update_base_lvim()
+    if ret then
+      reload("lvim.utils.hooks").run_post_update()
+    end
+  end)
 end
 end
 
 
 return M
 return M

+ 1 - 1
lua/lvim/config/defaults.lua

@@ -26,7 +26,7 @@ return {
   lang = {},
   lang = {},
   log = {
   log = {
     ---@usage can be { "trace", "debug", "info", "warn", "error", "fatal" },
     ---@usage can be { "trace", "debug", "info", "warn", "error", "fatal" },
-    level = "warn",
+    level = "info",
     viewer = {
     viewer = {
       ---@usage this will fallback on "less +F" if not found
       ---@usage this will fallback on "less +F" if not found
       cmd = "lnav",
       cmd = "lnav",

+ 2 - 1
lua/lvim/core/log.lua

@@ -41,7 +41,7 @@ function Log:init()
     lvim = {
     lvim = {
       sinks = {
       sinks = {
         structlog.sinks.Console(log_level, {
         structlog.sinks.Console(log_level, {
-          async = true,
+          async = false,
           processors = {
           processors = {
             structlog.processors.Namer(),
             structlog.processors.Namer(),
             structlog.processors.StackWriter({ "line", "file" }, { max_parents = 0, stack_level = 2 }),
             structlog.processors.StackWriter({ "line", "file" }, { max_parents = 0, stack_level = 2 }),
@@ -68,6 +68,7 @@ function Log:init()
     },
     },
   }
   }
 
 
+  lvim_log.lvim.sinks[1].async = false -- HACK: Bug in structlog prevents setting async to false
   structlog.configure(lvim_log)
   structlog.configure(lvim_log)
   local logger = structlog.get_logger "lvim"
   local logger = structlog.get_logger "lvim"