Software /
code /
prosody
Diff
core/loggingmanager.lua @ 8226:3463d82276de
loggingmanager, mod_posix: Replace the old inconsistent log formatting with the new util.format
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 10 Sep 2017 13:05:45 -0400 |
parent | 7949:8acc35b5355a |
child | 8227:325371632fe6 |
line wrap: on
line diff
--- a/core/loggingmanager.lua Sun Sep 10 12:42:05 2017 -0400 +++ b/core/loggingmanager.lua Sun Sep 10 13:05:45 2017 -0400 @@ -7,7 +7,7 @@ -- -- luacheck: globals log prosody.log -local format = string.format; +local format = require "util.format"; local setmetatable, rawset, pairs, ipairs, type = setmetatable, rawset, pairs, ipairs, type; local stdout = io.stdout; @@ -195,22 +195,13 @@ 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 - write(logfile, timestamps and os_date(timestamps) or "", name, level, "\t", message, "\n"); + write(logfile, timestamps and os_date(timestamps) or "", name, level, "\t", format(message, ...), "\n"); end end log_sink_types.file = log_to_file;