Skip to content

Commit

Permalink
优化日志
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyoo0812 committed Sep 25, 2023
1 parent a83de03 commit 93cdaff
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions script/basic/logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local LOG_LEVEL = log.LOG_LEVEL

local title = quanta.title
local monitors = _ENV.monitors or {}
local dispatch = false

logger = {}
logfeature = {}
Expand Down Expand Up @@ -87,10 +88,14 @@ for lvl, conf in pairs(LOG_LEVEL_OPTIONS) do
local lvl_name, flag = tunpack(conf)
logger[lvl_name] = function(fmt, ...)
local msg = logger_output(flag, "", lvl, lvl_name, fmt, ...)
if msg then
for monitor in pairs(monitors) do
monitor:dispatch_log(msg, lvl_name)
end
if msg and (not dispatch) then
dispatch = true
pcall(function ()
for monitor in pairs(monitors) do
monitor:dispatch_log(msg, lvl_name)
end
end)
dispatch = false
end
end
end
Expand Down

0 comments on commit 93cdaff

Please sign in to comment.