Software /
code /
prosody
Changeset
11641:b03053ec6dcf
core.loggingmanager: Support passing log messages trough a filter
This will be used by the console logger for pretty printing.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 29 Jun 2021 16:05:35 +0200 |
parents | 11640:51598e46e136 |
children | 11642:7f2dee4249aa |
files | core/loggingmanager.lua |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/core/loggingmanager.lua Sat Nov 07 22:09:46 2020 +0100 +++ b/core/loggingmanager.lua Tue Jun 29 16:05:35 2021 +0200 @@ -36,6 +36,8 @@ local get_levels; local logging_levels = { "debug", "info", "warn", "error" } +local function id(x) return x end + -- 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) @@ -184,15 +186,16 @@ -- Column width for "source" (used by stdout and console) local sourcewidth = sink_config.source_width; + local filter = sink_config.filter or id; if sourcewidth then return function (name, level, message, ...) sourcewidth = math_max(#name+2, sourcewidth); - write(logfile, timestamps and os_date(timestamps) or "", name, rep(" ", sourcewidth-#name), level, "\t", format(message, ...), "\n"); + write(logfile, timestamps and os_date(timestamps) or "", name, rep(" ", sourcewidth-#name), level, "\t", filter(format(message, ...)), "\n"); end else return function (name, level, message, ...) - write(logfile, timestamps and os_date(timestamps) or "", name, "\t", level, "\t", format(message, ...), "\n"); + write(logfile, timestamps and os_date(timestamps) or "", name, "\t", level, "\t", filter(format(message, ...)), "\n"); end end end