+ end
+end
+
+local syslog_opened;
+function syslog_sink_maker(config)
+ if not syslog_opened then
+ pposix.syslog_open("prosody", module:get_option_string("syslog_facility"));
+ 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);
+
+local daemonize = module:get_option("daemonize");
+if daemonize == nil then
+ local no_daemonize = module:get_option("no_daemonize"); --COMPAT w/ 0.5
+ daemonize = not no_daemonize;
+ if no_daemonize ~= nil then
+ module:log("warn", "The 'no_daemonize' option is now replaced by 'daemonize'");
+ module:log("warn", "Update your config from 'no_daemonize = %s' to 'daemonize = %s'", tostring(no_daemonize), tostring(daemonize));
+ end
+end
+
+local function remove_log_sinks()
+ local lm = require "core.loggingmanager";
+ lm.register_sink_type("console", nil);
+ lm.register_sink_type("stdout", nil);
+ lm.reload_logging();
+end
+
+if daemonize then
+ local function daemonize_server()
+ module:log("info", "Prosody is about to detach from the console, disabling further console output");
+ remove_log_sinks();