# HG changeset patch # User Kim Alvefur # Date 1454615137 -3600 # Node ID 2f9088c663c660f9fa8900afec96fee8f4d66900 # Parent ae1d53c2f5980bff58eb9701e3ff35c7f016ce53 loggingmanager: Stringify all arguments to format so we can finally see the *real* error messages diff -r ae1d53c2f598 -r 2f9088c663c6 core/loggingmanager.lua --- a/core/loggingmanager.lua Thu Feb 04 18:40:24 2016 +0100 +++ b/core/loggingmanager.lua Thu Feb 04 20:45:37 2016 +0100 @@ -15,6 +15,8 @@ local math_max, rep = math.max, string.rep; local os_date = os.date; local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring; +local tostring = tostring; +local unpack = table.unpack or unpack; local config = require "core.configmanager"; local logger = require "util.logger"; @@ -192,17 +194,22 @@ local sourcewidth = sink_config.source_width; return function (name, level, message, ...) + local n = select('#', ...); + if n ~= 0 then + local arg = { ... }; + for i = 1, n do + arg[i] = tostring(arg[i]); + end + message = format(message, unpack(arg, 1, n)); + end + if sourcewidth then sourcewidth = math_max(#name+2, sourcewidth); name = name .. rep(" ", sourcewidth-#name); else name = name .. "\t"; end - if ... then - write(logfile, timestamps and os_date(timestamps) or "", name, level, "\t", format(message, ...), "\n"); - else - write(logfile, timestamps and os_date(timestamps) or "", name, level, "\t", message, "\n"); - end + write(logfile, timestamps and os_date(timestamps) or "", name, level, "\t", message, "\n"); end end log_sink_types.file = log_to_file;