From 2254f427a96b94de52272825feed5369698d5a5c Mon Sep 17 00:00:00 2001
From: Lukas Zapletal <lzap+git@redhat.com>
Date: Mon, 22 Oct 2018 12:57:58 +0200
Subject: [PATCH] Fixes #25239 - improved reporting exceptions
---
lib/smart_proxy_dynflow_core/log.rb | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/lib/smart_proxy_dynflow_core/log.rb b/lib/smart_proxy_dynflow_core/log.rb
index fc0aa3c..5954c21 100644
--- a/lib/smart_proxy_dynflow_core/log.rb
+++ b/lib/smart_proxy_dynflow_core/log.rb
@@ -54,13 +54,28 @@ module SmartProxyDynflowCore
end
end
+ class ProxyStructuredFormater < ::Dynflow::LoggerAdapters::Formatters::Abstract
+ def call(_severity, _datetime, _prog_name, message)
+ if ::Exception === message
+ @base.exception("Error details", message)
+ "#{message.message} (#{message.class})"
+ else
+ message
+ end
+ end
+
+ def format(message)
+ call(nil, nil, nil, message)
+ end
+ end
+
class ProxyAdapter < ::Dynflow::LoggerAdapters::Simple
- def initialize(logger, level = Logger::DEBUG, formatters = [::Dynflow::LoggerAdapters::Formatters::Exception])
+ def initialize(logger, level = Logger::DEBUG, formatters = [])
@logger = logger
@logger.level = level
- @logger.formatter = method(:formatter).to_proc
- @action_logger = apply_formatters ProgNameWrapper.new(@logger, ' action'), formatters
- @dynflow_logger = apply_formatters ProgNameWrapper.new(@logger, 'dynflow'), formatters
+ @logger.formatter = ProxyStructuredFormater.new(@logger)
+ @action_logger = apply_formatters(ProgNameWrapper.new(@logger, ' action'), [ProxyStructuredFormater])
+ @dynflow_logger = apply_formatters(ProgNameWrapper.new(@logger, 'dynflow'), [ProxyStructuredFormater])
end
end
end
--
2.17.2