diff options
author | Waqas Hussain <waqas20@gmail.com> | 2017-09-10 13:05:45 -0400 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2017-09-10 13:05:45 -0400 |
commit | 00cb31f022a3325e4e182b666f85a6b4e05b7a7e (patch) | |
tree | e88b65d8d20941d8135c35f87a04a82ca644d1d6 | |
parent | 347f3ab6a3e1f7f64a9289ec08c081f79bef9087 (diff) | |
download | prosody-00cb31f022a3325e4e182b666f85a6b4e05b7a7e.tar.gz prosody-00cb31f022a3325e4e182b666f85a6b4e05b7a7e.zip |
loggingmanager, mod_posix: Replace the old inconsistent log formatting with the new util.format
-rw-r--r-- | core/loggingmanager.lua | 13 | ||||
-rw-r--r-- | plugins/mod_posix.lua | 9 |
2 files changed, 5 insertions, 17 deletions
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua index 14305588..1b888a7e 100644 --- a/core/loggingmanager.lua +++ b/core/loggingmanager.lua @@ -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 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 - 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; diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index 32fc27bc..b2984add 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -20,6 +20,7 @@ if not have_signal then module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); end +local format = require "util.format"; local lfs = require "lfs"; local stat = lfs.attributes; @@ -118,13 +119,9 @@ function syslog_sink_maker(config) -- luacheck: ignore 212/config pposix.syslog_open("prosody", module:get_option_string("syslog_facility")); syslog_opened = true; end - local syslog, format = pposix.syslog_log, string.format; + local syslog = pposix.syslog_log; return function (name, level, message, ...) - if ... then - syslog(level, name, format(message, ...)); - else - syslog(level, name, message); - end + syslog(level, name, format(message, ...)); end; end require "core.loggingmanager".register_sink_type("syslog", syslog_sink_maker); |