aboutsummaryrefslogtreecommitdiffstats
path: root/core/loggingmanager.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-09-14 02:48:34 +0200
committerKim Alvefur <zash@zash.se>2017-09-14 02:48:34 +0200
commit2547ccfe3d26fbf57e0ecddf5cfd5d21377c3633 (patch)
treeae64d69a765500ad798ce354363683ab22571fa3 /core/loggingmanager.lua
parent8483401b3203a6745fafea2303727732c8f08ec7 (diff)
parent3937703c4d9a2ea3200d93d7e3a1eecea3f1e1cb (diff)
downloadprosody-2547ccfe3d26fbf57e0ecddf5cfd5d21377c3633.tar.gz
prosody-2547ccfe3d26fbf57e0ecddf5cfd5d21377c3633.zip
Merge 0.10->trunk
Diffstat (limited to 'core/loggingmanager.lua')
-rw-r--r--core/loggingmanager.lua27
1 files changed, 8 insertions, 19 deletions
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index 14305588..6dc1c1d1 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".format;
local setmetatable, rawset, pairs, ipairs, type =
setmetatable, rawset, pairs, ipairs, type;
local stdout = io.stdout;
@@ -15,9 +15,6 @@ 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 select = select;
-local unpack = table.unpack or unpack; --luacheck: ignore 113
local config = require "core.configmanager";
local logger = require "util.logger";
@@ -194,23 +191,15 @@ local function log_to_file(sink_config, logfile)
-- Column width for "source" (used by stdout and console)
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
+ if sourcewidth then
+ return function (name, level, message, ...)
sourcewidth = math_max(#name+2, sourcewidth);
- name = name .. rep(" ", sourcewidth-#name);
- else
- name = name .. "\t";
+ write(logfile, timestamps and os_date(timestamps) or "", name, rep(" ", sourcewidth-#name), level, "\t", format(message, ...), "\n");
+ end
+ else
+ return function (name, level, message, ...)
+ write(logfile, timestamps and os_date(timestamps) or "", name, "\t", level, "\t", format(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;