aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-02-04 20:45:37 +0100
committerKim Alvefur <zash@zash.se>2016-02-04 20:45:37 +0100
commit1ca9c3d5200f76d6aa0bc8ab47d288b4b5fe6179 (patch)
tree0dc4f24be0a2da8b75e67ff86dae9528e0a2d4cd
parent47f497ad9364b3f6af3e66b771fdc7cb9ed17f7b (diff)
downloadprosody-1ca9c3d5200f76d6aa0bc8ab47d288b4b5fe6179.tar.gz
prosody-1ca9c3d5200f76d6aa0bc8ab47d288b4b5fe6179.zip
loggingmanager: Stringify all arguments to format so we can finally see the *real* error messages
-rw-r--r--core/loggingmanager.lua17
1 files changed, 12 insertions, 5 deletions
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index 64e1ea77..77d31964 100644
--- a/core/loggingmanager.lua
+++ b/core/loggingmanager.lua
@@ -15,6 +15,8 @@ local io_open = io.open;
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 function log_to_file(sink_config, logfile)
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;