Software /
code /
prosody
Comparison
core/loggingmanager.lua @ 3514:fdae08713c67
core.loggingmanager: Logging config simplification - allow [level] = filename and *sink to appear in the config table
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 08 Oct 2010 02:48:47 +0100 |
parent | 3438:9a8b716fda14 |
child | 3540:bc139431830b |
comparison
equal
deleted
inserted
replaced
3513:4cf5962747fc | 3514:fdae08713c67 |
---|---|
87 -- Search for all rules using a particular sink type, and apply | 87 -- Search for all rules using a particular sink type, and apply |
88 -- them. Called automatically when a new sink type is added to | 88 -- them. Called automatically when a new sink type is added to |
89 -- the log_sink_types table. | 89 -- the log_sink_types table. |
90 function apply_sink_rules(sink_type) | 90 function apply_sink_rules(sink_type) |
91 if type(logging_config) == "table" then | 91 if type(logging_config) == "table" then |
92 | |
93 if sink_type == "file" then | |
94 for _, level in ipairs(logging_levels) do | |
95 if type(logging_config[level]) == "string" then | |
96 add_rule({ | |
97 to = "file", | |
98 filename = logging_config[level], | |
99 timestamps = true, | |
100 levels = { min = level }, | |
101 }); | |
102 end | |
103 end | |
104 end | |
105 | |
92 for _, sink_config in pairs(logging_config) do | 106 for _, sink_config in pairs(logging_config) do |
93 if sink_config.to == sink_type then | 107 if (type(sink_config) == "table" and sink_config.to == sink_type) then |
94 add_rule(sink_config); | 108 add_rule(sink_config); |
109 elseif (type(sink_config) == "string" and sink_config:match("^%*(.+)") == sink_type) then | |
110 add_rule({ levels = { min = "debug" }, to = sink_type }); | |
95 end | 111 end |
96 end | 112 end |
97 elseif type(logging_config) == "string" and (not logging_config:match("^%*")) and sink_type == "file" then | 113 elseif type(logging_config) == "string" and (not logging_config:match("^%*")) and sink_type == "file" then |
98 -- User specified simply a filename, and the "file" sink type | 114 -- User specified simply a filename, and the "file" sink type |
99 -- was just added | 115 -- was just added |
149 end | 165 end |
150 | 166 |
151 logger.reset(); | 167 logger.reset(); |
152 | 168 |
153 default_logging = { { to = "console" , levels = { min = (debug_mode and "debug") or "info" } } }; | 169 default_logging = { { to = "console" , levels = { min = (debug_mode and "debug") or "info" } } }; |
154 default_file_logging = { { to = "file", levels = { min = (debug_mode and "debug") or "info" }, timestamps = true } }; | 170 default_file_logging = { |
171 { to = "file", levels = { min = (debug_mode and "debug") or "info" }, timestamps = true } | |
172 }; | |
155 default_timestamp = "%b %d %H:%M:%S"; | 173 default_timestamp = "%b %d %H:%M:%S"; |
156 | 174 |
157 logging_config = config.get("*", "core", "log") or default_logging; | 175 logging_config = config.get("*", "core", "log") or default_logging; |
158 | 176 |
159 | 177 |