Comparison

plugins/mod_posix.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 8167:39188851811c
child 8228:cda9db4b881d
comparison
equal deleted inserted replaced
8225:70cb72f46a3b 8226:3463d82276de
18 local have_signal, signal = pcall(require, "util.signal"); 18 local have_signal, signal = pcall(require, "util.signal");
19 if not have_signal then 19 if not have_signal then
20 module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); 20 module:log("warn", "Couldn't load signal library, won't respond to SIGTERM");
21 end 21 end
22 22
23 local format = require "util.format";
23 local lfs = require "lfs"; 24 local lfs = require "lfs";
24 local stat = lfs.attributes; 25 local stat = lfs.attributes;
25 26
26 local prosody = _G.prosody; 27 local prosody = _G.prosody;
27 28
116 function syslog_sink_maker(config) -- luacheck: ignore 212/config 117 function syslog_sink_maker(config) -- luacheck: ignore 212/config
117 if not syslog_opened then 118 if not syslog_opened then
118 pposix.syslog_open("prosody", module:get_option_string("syslog_facility")); 119 pposix.syslog_open("prosody", module:get_option_string("syslog_facility"));
119 syslog_opened = true; 120 syslog_opened = true;
120 end 121 end
121 local syslog, format = pposix.syslog_log, string.format; 122 local syslog = pposix.syslog_log;
122 return function (name, level, message, ...) 123 return function (name, level, message, ...)
123 if ... then 124 syslog(level, name, format(message, ...));
124 syslog(level, name, format(message, ...));
125 else
126 syslog(level, name, message);
127 end
128 end; 125 end;
129 end 126 end
130 require "core.loggingmanager".register_sink_type("syslog", syslog_sink_maker); 127 require "core.loggingmanager".register_sink_type("syslog", syslog_sink_maker);
131 128
132 local daemonize = module:get_option("daemonize", prosody.installed); 129 local daemonize = module:get_option("daemonize", prosody.installed);