X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=core%2Floggingmanager.lua;h=88f2bbbf506453d349427e2cb10de667ab2f200f;hb=893e9d4df9981fa666c98c0f5dd04920ae91e955;hp=40b96d52b7359ecadc754028eedeb422c96bf7f5;hpb=66aa41fed1fc6fb6f49f7a57697ff3cbc31f1c72;p=prosody.git diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua index 40b96d52..88f2bbbf 100644 --- a/core/loggingmanager.lua +++ b/core/loggingmanager.lua @@ -27,8 +27,6 @@ local config = require "core.configmanager"; local logger = require "util.logger"; local prosody = prosody; -local debug_mode = config.get("*", "core", "debug"); - _G.log = logger.init("general"); module "loggingmanager" @@ -90,20 +88,26 @@ end function apply_sink_rules(sink_type) if type(logging_config) == "table" then - if sink_type == "file" then - for _, level in ipairs(logging_levels) do - if type(logging_config[level]) == "string" then + for _, level in ipairs(logging_levels) do + if type(logging_config[level]) == "string" then + local value = logging_config[level]; + if sink_type == "file" then + add_rule({ + to = sink_type; + filename = value; + timestamps = true; + levels = { min = level }; + }); + elseif value == "*"..sink_type then add_rule({ - to = "file", - filename = logging_config[level], - timestamps = true, - levels = { min = level }, + to = sink_type; + levels = { min = level }; }); end end end - for _, sink_config in pairs(logging_config) do + for _, sink_config in ipairs(logging_config) do if (type(sink_config) == "table" and sink_config.to == sink_type) then add_rule(sink_config); elseif (type(sink_config) == "string" and sink_config:match("^%*(.+)") == sink_type) then @@ -166,6 +170,8 @@ function reload_logging() logger.reset(); + local debug_mode = config.get("*", "core", "debug"); + default_logging = { { to = "console" , levels = { min = (debug_mode and "debug") or "info" } } }; default_file_logging = { { to = "file", levels = { min = (debug_mode and "debug") or "info" }, timestamps = true } @@ -195,7 +201,7 @@ end -- Column width for "source" (used by stdout and console) local sourcewidth = 20; -function log_sink_types.stdout() +function log_sink_types.stdout(config) local timestamps = config.timestamps; if timestamps == true then @@ -266,12 +272,6 @@ function log_sink_types.file(config) end local write, flush = logfile.write, logfile.flush; - prosody.events.add_handler("logging-reloading", function () - if logfile then - logfile:close(); - end - end); - local timestamps = config.timestamps; if timestamps == nil or timestamps == true then