6 local tostring = tostring; |
6 local tostring = tostring; |
7 local math_max = math.max; |
7 local math_max = math.max; |
8 |
8 |
9 local logger = require "util.logger"; |
9 local logger = require "util.logger"; |
10 |
10 |
|
11 local default_logging = { { to = "console" } }; |
|
12 |
11 -- Global log function, because some people are too |
13 -- Global log function, because some people are too |
12 -- lazy to get their own... |
14 -- lazy to get their own... |
13 _G.log = logger.init("general"); |
15 _G.log = logger.init("general"); |
14 |
16 |
15 local log_sink_types = {}; |
17 local log_sink_types = {}; |
16 local get_levels; |
18 local get_levels; |
|
19 local logging_levels = { "debug", "info", "warn", "error", "critical" } |
17 |
20 |
18 --- Main function to read config, create the appropriate sinks and tell logger module |
21 --- Main function to read config, create the appropriate sinks and tell logger module |
19 function setup_logging(log) |
22 function setup_logging(log) |
20 log = log or config.get("*", "core", "log") or default_logging; |
23 log = log or config.get("*", "core", "log") or default_logging; |
21 -- Set default logger |
24 -- Set default logger |
127 |
137 |
128 function log_sink_types.syslog() |
138 function log_sink_types.syslog() |
129 end |
139 end |
130 |
140 |
131 --- Helper function to get a set of levels given a "criteria" table |
141 --- Helper function to get a set of levels given a "criteria" table |
132 local logging_levels = { "debug", "info", "warn", "error", "critical" } |
|
133 |
|
134 function get_levels(criteria, set) |
142 function get_levels(criteria, set) |
135 set = set or {}; |
143 set = set or {}; |
136 if type(criteria) == "string" then |
144 if type(criteria) == "string" then |
137 set[criteria] = true; |
145 set[criteria] = true; |
138 return set; |
146 return set; |