Skip to content

Commit 01106ed

Browse files
line0CoffeeFlux
authored andcommitted
Logger: don't try to format messages when no matching varargs are supplied
prevents the logger from throwing an error when faced with poorly crafted messages, which previously masked actual errors
1 parent 4625d57 commit 01106ed

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

modules/DependencyControl/Logger.moon

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ class Logger
4747
prefixWin = @usePrefixWindow and prefix or ""
4848
lineFeed = insertLineFeed and "\n" or ""
4949
indentStr = indent==0 and "" or @indentStr\rep(indent) .. " "
50-
msg = @lastHadLineFeed and @format(msg, indent, ...) or msg\format ...
50+
51+
msg = if @lastHadLineFeed
52+
@format msg, indent, ...
53+
elseif 0 < select "#", ...
54+
msg\format ...
5155

5256
show = aegisub.log and @toWindow
5357
if @toFile and level <= @maxToFileLevel
@@ -67,7 +71,10 @@ class Logger
6771
format: (msg, indent, ...) =>
6872
if type(msg) == "table"
6973
msg = table.concat msg, "\n"
70-
msg = msg\format ...
74+
75+
if 0 < select "#", ...
76+
msg = msg\format ...
77+
7178
return msg unless indent>0
7279

7380
indentRep = @indentStr\rep(indent)

0 commit comments

Comments
 (0)