Skip to content

Commit

Permalink
Logger: don't try to format messages when no matching varargs are sup…
Browse files Browse the repository at this point in the history
…plied

prevents the logger from throwing an error when faced with poorly crafted messages, which previously masked actual errors
  • Loading branch information
line0 authored and CoffeeFlux committed Jan 7, 2019
1 parent 4625d57 commit 01106ed
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/DependencyControl/Logger.moon
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ class Logger
prefixWin = @usePrefixWindow and prefix or ""
lineFeed = insertLineFeed and "\n" or ""
indentStr = indent==0 and "" or @indentStr\rep(indent) .. " "
msg = @lastHadLineFeed and @format(msg, indent, ...) or msg\format ...

msg = if @lastHadLineFeed
@format msg, indent, ...
elseif 0 < select "#", ...
msg\format ...

show = aegisub.log and @toWindow
if @toFile and level <= @maxToFileLevel
Expand All @@ -67,7 +71,10 @@ class Logger
format: (msg, indent, ...) =>
if type(msg) == "table"
msg = table.concat msg, "\n"
msg = msg\format ...

if 0 < select "#", ...
msg = msg\format ...

return msg unless indent>0

indentRep = @indentStr\rep(indent)
Expand Down

0 comments on commit 01106ed

Please sign in to comment.