Comparison

plugins/mod_posix.lua @ 722:63456c9d0522

mod_posix: Support for logging to syslog (log = 'syslog' in config)
author Matthew Wild <mwild1@gmail.com>
date Thu, 15 Jan 2009 20:06:41 +0000
parent 594:6d9b2da9888f
child 723:c1e7d280c174
comparison
equal deleted inserted replaced
721:51233a8ae3d4 722:63456c9d0522
9 if not config_get("*", "core", "no_daemonize") then 9 if not config_get("*", "core", "no_daemonize") then
10 local function daemonize_server() 10 local function daemonize_server()
11 local logwriter; 11 local logwriter;
12 12
13 local logfilename = config_get("*", "core", "log"); 13 local logfilename = config_get("*", "core", "log");
14 if logfilename then 14 if logfilename == "syslog" then
15 pposix.syslog_open("prosody");
16 local syslog, format = pposix.syslog_log, string.format;
17 logwriter = function (name, level, message, ...)
18 if ... then
19 syslog(level, format(message, ...));
20 else
21 syslog(level, message);
22 end
23 end;
24 elseif logfilename then
15 local logfile = io.open(logfilename, "a+"); 25 local logfile = io.open(logfilename, "a+");
16 if logfile then 26 if logfile then
17 local write, format, flush = logfile.write, string.format, logfile.flush; 27 local write, format, flush = logfile.write, string.format, logfile.flush;
18 logwriter = function (name, level, message, ...) 28 logwriter = function (name, level, message, ...)
19 if ... then 29 if ... then