aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--util/logger.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/logger.lua b/util/logger.lua
index e72b29bc..ee257868 100644
--- a/util/logger.lua
+++ b/util/logger.lua
@@ -67,10 +67,21 @@ local function add_level_sink(level, sink_function)
end
end
+local function add_simple_sink(simple_sink_function, levels)
+ local format = require "util.format".format;
+ local function sink_function(name, level, msg, ...)
+ return simple_sink_function(name, level, format(msg, ...));
+ end
+ for _, level in ipairs(levels or {"debug", "info", "warn", "error"}) do
+ add_level_sink(level, sink_function);
+ end
+end
+
return {
init = init;
make_logger = make_logger;
reset = reset;
add_level_sink = add_level_sink;
+ add_simple_sink = add_simple_sink;
new = make_logger;
};