From 585dac714a2f6f197035e40701201d4f2474f616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 10 Nov 2020 11:56:35 +0800 Subject: =?UTF-8?q?#243=20=E6=97=A5=E5=BF=97=E5=A2=9E=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/log.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'script-beta/log.lua') diff --git a/script-beta/log.lua b/script-beta/log.lua index 6af189dc..257ef7bb 100644 --- a/script-beta/log.lua +++ b/script-beta/log.lua @@ -48,9 +48,6 @@ local function pushLog(level, ...) if not m.path then return end - if m.size > m.maxSize then - return - end local t = tablePack(...) for i = 1, t.n do t[i] = tostring(t[i]) @@ -87,6 +84,9 @@ function m.raw(thd, level, msg, source, currentline, clock) if level == 'error' then ioStdErr:write(msg .. '\n') end + if m.size > m.maxSize then + return + end init_log_file() if not m.file then return '' @@ -103,10 +103,12 @@ function m.raw(thd, level, msg, source, currentline, clock) else buf = ('[%s.%03.f][%s]%s[#%d:%s:%s]: %s\n'):format(timestr, ms * 1000, level, agl, thd, trimSrc(source), currentline, msg) end - m.file:write(buf) m.size = m.size + #buf if m.size > m.maxSize then + m.file:write(buf:sub(1, m.size - m.maxSize)) m.file:write('[REACH MAX SIZE]') + else + m.file:write(buf) end return buf end -- cgit v1.2.3