aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-04-29 20:53:33 +0100
committerMatthew Wild <mwild1@gmail.com>2009-04-29 20:53:33 +0100
commit5553cf3c48dbcbdc66fa734ce9371793d42d48bc (patch)
tree373eb17cd49b348160912484585c1fc4b8dccd60
parent544704ff815efee4204636f302dfb5deed3463d7 (diff)
parent3015c946d18d28566fd92201291a33b0872eccc1 (diff)
downloadprosody-5553cf3c48dbcbdc66fa734ce9371793d42d48bc.tar.gz
prosody-5553cf3c48dbcbdc66fa734ce9371793d42d48bc.zip
Merge with 0.4
-rw-r--r--core/loggingmanager.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index 298e4c45..5dff6a34 100644
--- a/core/loggingmanager.lua
+++ b/core/loggingmanager.lua
@@ -19,6 +19,7 @@ module "loggingmanager"
-- The log config used if none specified in the config file
local default_logging = { { to = "console" } };
+local default_file_logging = { { to = "file", levels = { min = "info" } } };
-- The actual config loggingmanager is using
local logging_config = config.get("*", "core", "log") or default_logging;
@@ -28,6 +29,8 @@ local log_sink_types = setmetatable({}, { __newindex = function (t, k, v) rawset
local get_levels;
local logging_levels = { "debug", "info", "warn", "error", "critical" }
+-- Put a rule into action. Requires that the sink type has already been registered.
+-- This function is called automatically when a new sink type is added [see apply_sink_rules()]
local function add_rule(sink_config)
local sink_maker = log_sink_types[sink_config.to];
if sink_maker then
@@ -65,8 +68,9 @@ local function add_rule(sink_config)
end
end
--- Search for all rules using a particular sink type,
--- and apply them
+-- Search for all rules using a particular sink type, and apply
+-- them. Called automatically when a new sink type is added to
+-- the log_sink_types table.
function apply_sink_rules(sink_type)
if type(logging_config) == "table" then
for _, sink_config in pairs(logging_config) do
@@ -74,9 +78,14 @@ function apply_sink_rules(sink_type)
add_rule(sink_config);
end
end
- elseif type(logging_config) == "string" and sink_type == "file" then
+ elseif type(logging_config) == "string" and (not logging_config:match("^%*")) and sink_type == "file" then
-- User specified simply a filename, and the "file" sink type
-- was just added
+ for _, sink_config in pairs(default_file_logging) do
+ sink_config.filename = logging_config;
+ add_rule(sink_config);
+ sink_config.filename = nil;
+ end
end
end