aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-06-29 16:07:57 +0200
committerKim Alvefur <zash@zash.se>2021-06-29 16:07:57 +0200
commitbfb4514d0fc0aeaacf9f5fb741d67fd36bd2774a (patch)
treea1153cf6426842b7998162ecf87538887ae6d351 /core
parentf40173b4c7d7e31d0264964de0999559c4f4e28f (diff)
downloadprosody-bfb4514d0fc0aeaacf9f5fb741d67fd36bd2774a.tar.gz
prosody-bfb4514d0fc0aeaacf9f5fb741d67fd36bd2774a.zip
core.loggingmanager: Pretty-print logged XML snippets in console
This replaces an earlier method in a private extension that logged pretty-printed XML, which broke due to the escaping added in util.format
Diffstat (limited to 'core')
-rw-r--r--core/loggingmanager.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index c5b658c8..e4ab32b5 100644
--- a/core/loggingmanager.lua
+++ b/core/loggingmanager.lua
@@ -14,6 +14,7 @@ local io_open = io.open;
local math_max, rep = math.max, string.rep;
local os_date = os.date;
local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring;
+local st = require "util.stanza";
local config = require "core.configmanager";
local logger = require "util.logger";
@@ -214,20 +215,23 @@ log_sink_types.stdout = log_to_stdout;
local do_pretty_printing = true;
-local logstyles;
+local logstyles, pretty;
if do_pretty_printing then
logstyles = {};
logstyles["info"] = getstyle("bold");
logstyles["warn"] = getstyle("bold", "yellow");
logstyles["error"] = getstyle("bold", "red");
+
+ pretty = st.pretty_print;
end
local function log_to_console(sink_config)
-- Really if we don't want pretty colours then just use plain stdout
- local logstdout = log_to_stdout(sink_config);
if not do_pretty_printing then
- return logstdout;
+ return log_to_stdout(sink_config);
end
+ sink_config.filter = pretty;
+ local logstdout = log_to_stdout(sink_config);
return function (name, level, message, ...)
local logstyle = logstyles[level];
if logstyle then