Actions
Bug #25267
closedProvide Ruby logger API method formatter
Difficulty:
easy
Triaged:
Yes
Pull request:
Description
Smart Proxy Dynflow Core uses formatter method which is not defined in the logger decorator in proxy, this breaks compatibility with Ruby logger stack. Let's add it back.
Updated by Lukas Zapletal about 6 years ago
- Target version set to 1.20.0
- Fixed in Releases deleted (
1.20.0) - Found in Releases 1.20.0 added
Updated by Lukas Zapletal about 6 years ago
- Related to Bug #25239: undefined method 'formatter=' for Logging::RootLogger when running SPDC inside smart-proxy added
Updated by Lukas Zapletal about 6 years ago
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
Updated by The Foreman Bot about 6 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/smart-proxy/pull/619 added
Updated by Anonymous about 6 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset d8ed7fa82343568f41115d014ae7923e9e544bb1.
Actions