From 93cdaff34f88064276ec25828195604fe186e267 Mon Sep 17 00:00:00 2001 From: xiyoo0812 Date: Mon, 25 Sep 2023 14:23:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/basic/logger.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/script/basic/logger.lua b/script/basic/logger.lua index 462c85a6..a86bda04 100644 --- a/script/basic/logger.lua +++ b/script/basic/logger.lua @@ -13,6 +13,7 @@ local LOG_LEVEL = log.LOG_LEVEL local title = quanta.title local monitors = _ENV.monitors or {} +local dispatch = false logger = {} logfeature = {} @@ -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