aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-04-22 20:01:19 +0100
committerMatthew Wild <mwild1@gmail.com>2009-04-22 20:01:19 +0100
commitfc2a4159849cf5fcb2c53d4fb0c0f1a7b101d69a (patch)
tree1d586a5d74a1e0756645dfb520cc303f35f0fd5a /plugins
parentca533fa608318506d14639f02c2665c5a31cdcb4 (diff)
downloadprosody-fc2a4159849cf5fcb2c53d4fb0c0f1a7b101d69a.tar.gz
prosody-fc2a4159849cf5fcb2c53d4fb0c0f1a7b101d69a.zip
mod_posix: Integrate with loggingmanager, register syslog sink, remove redundant logging code
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_posix.lua51
1 files changed, 15 insertions, 36 deletions
diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua
index abf93a81..f8fda7cd 100644
--- a/plugins/mod_posix.lua
+++ b/plugins/mod_posix.lua
@@ -40,47 +40,26 @@ local function write_pidfile()
end
end
-local logfilename = config_get("*", "core", "log");
-if logfilename == "syslog" then
- pposix.syslog_open("prosody");
- pposix.syslog_setminlevel(config.get("*", "core", "minimum_log_level") or "info");
- local syslog, format = pposix.syslog_log, string.format;
- logwriter = function (name, level, message, ...)
- if ... then
- syslog(level, format(message, ...));
- else
- syslog(level, message);
- end
- end;
-elseif logfilename then
- local logfile = io.open(logfilename, "a+");
- if logfile then
- local write, format, flush = logfile.write, string.format, logfile.flush;
- logwriter = function (name, level, message, ...)
- if ... then
- write(logfile, name, "\t", level, "\t", format(message, ...), "\n");
- else
- write(logfile, name, "\t" , level, "\t", message, "\n");
- end
- flush(logfile);
- end;
- end
-else
- log("debug", "No logging specified, will continue with default");
-end
-
-if logwriter then
- local ok, ret = logger_set(logwriter);
- if not ok then
- log("error", "Couldn't set new log output: %s", ret);
+local syslog_opened
+function syslog_sink_maker(config)
+ if not syslog_opened then
+ print("OPENING SYSLOOOOOOOOOG");
+ pposix.syslog_open("prosody");
+ syslog_opened = true;
end
+ local syslog, format = pposix.syslog_log, string.format;
+ return function (name, level, message, ...)
+ if ... then
+ syslog(level, format(message, ...));
+ else
+ syslog(level, message);
+ end
+ end;
end
+require "core.loggingmanager".register_sink_type("syslog", syslog_sink_maker);
if not config_get("*", "core", "no_daemonize") then
local function daemonize_server()
- local logwriter;
-
-
local ok, ret = pposix.daemonize();
if not ok then
log("error", "Failed to daemonize: %s", ret);