@@ -12,8 +12,6 @@ local mathModf = math.modf
1212local debugGetInfo = debug.getinfo
1313local ioStdErr = io.stderr
1414
15- _ENV = nil
16-
1715local m = {}
1816
1917m .file = nil
@@ -91,9 +89,6 @@ function m.raw(thd, level, msg, source, currentline, clock)
9189 return
9290 end
9391 init_log_file ()
94- if not m .file then
95- return ' '
96- end
9792 local sec , ms = mathModf ((m .startTime + clock ) / 1000 )
9893 local timestr = osDate (' %H:%M:%S' , sec )
9994 local agl = ' '
@@ -107,11 +102,13 @@ function m.raw(thd, level, msg, source, currentline, clock)
107102 buf = (' [%s.%03.f][%s]%s[#%d:%s:%s]: %s\n ' ):format (timestr , ms * 1000 , level , agl , thd , trimSrc (source ), currentline , msg )
108103 end
109104 m .size = m .size + # buf
110- if m .size > m .maxSize then
111- m .file :write (buf :sub (1 , m .size - m .maxSize ))
112- m .file :write (' [REACH MAX SIZE]' )
113- else
114- m .file :write (buf )
105+ if m .file then
106+ if m .size > m .maxSize then
107+ m .file :write (buf :sub (1 , m .size - m .maxSize ))
108+ m .file :write (' [REACH MAX SIZE]' )
109+ else
110+ m .file :write (buf )
111+ end
115112 end
116113 return buf
117114end
@@ -130,9 +127,11 @@ function m.init(root, path)
130127 m .path = path :string ()
131128 m .prefixLen = # root :string ()
132129 m .size = 0
133- if not fs .exists (path :parent_path ()) then
134- fs .create_directories (path :parent_path ())
135- end
130+ pcall (function ()
131+ if not fs .exists (path :parent_path ()) then
132+ fs .create_directories (path :parent_path ())
133+ end
134+ end )
136135 if lastBuf then
137136 init_log_file ()
138137 if m .file then
0 commit comments