# HG changeset patch # User Matthew Wild # Date 1241034813 -3600 # Node ID 5a655479db72fbec72af848ef4355e47898c919f # Parent 0cb325970a50fd88113bbdf0a89589ceed80024a# Parent 21f41b06f1d2f29843fe4c49605079ab68c95bb3 Merge with 0.4 diff -r 0cb325970a50 -r 5a655479db72 core/loggingmanager.lua --- a/core/loggingmanager.lua Wed Apr 29 02:08:55 2009 +0100 +++ b/core/loggingmanager.lua Wed Apr 29 20:53:33 2009 +0100 @@ -19,6 +19,7 @@ -- 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 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 @@ 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 @@ 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