Project

General

Profile

Bug #25239

undefined method 'formatter=' for Logging::RootLogger when running SPDC inside smart-proxy

Added by Adam Ruzicka 9 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Proxy plugin
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When SPDC was running as a part of smart-proxy we used to reuse the logger from the smart-proxy. With recent changes to the logging stack in smart-proxy our logger-reuse code not longer works


Related issues

Related to Smart Proxy - Refactor #25100: Replace Ruby logging stack with logging gemClosed
Related to Smart Proxy - Bug #25267: Provide Ruby logger API method formatterClosed

Associated revisions

Revision 2b6ccc2c (diff)
Added by Lukas Zapletal 6 months ago

Fixes #25239 - improved reporting exceptions (#56)

History

#1 Updated by Adam Ruzicka 9 months ago

  • Related to Refactor #25100: Replace Ruby logging stack with logging gem added

#2 Updated by Daniel Lobato Garcia 9 months ago

For the record, I'm trying to run SPDC (smart proxy dynflow core) as a separate process in development, to do so I basically follow https://github.com/theforeman/smart_proxy_dynflow#the-separate-dynflow-way.

Even after running 'bundle exec bin/smart_proxy_dynflow_core' separately and pointing to that instance via settings.d/dynflow.yml (:core_url: http://127.0.0.1:8008), I still get the error you reported by trying to visit http://smart-proxy-fqdn:8000/version.

How do you run SPDC separately so this error doesn't show up?

#3 Updated by Lukas Zapletal 9 months ago

Hmmm sorry, this went into 1.20. I had no idea that dynflow re-uses that. Foreman core and proxy now uses https://github.com/TwP/logging which is easily extensible. Let me know if you need an assistance with this.

#4 Updated by Lukas Zapletal 9 months ago

  • Related to Bug #25267: Provide Ruby logger API method formatter added

#5 Updated by Lukas Zapletal 9 months ago

[lzap@box smart-proxy]$ cat 0001-Fixes-25267-Provide-Ruby-logger-API-method-formatter.patch 
From 34c0ae0d7e26266585de79da69473dc9b0e90752 Mon Sep 17 00:00:00 2001
From: Lukas Zapletal <lzap+gitxredhat.com>
Date: Mon, 22 Oct 2018 12:50:15 +0200
Subject: [PATCH] Fixes #25267 - Provide Ruby logger API method formatter

---
 lib/proxy/log_buffer/decorator.rb | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/proxy/log_buffer/decorator.rb b/lib/proxy/log_buffer/decorator.rb
index 21b6288..88d2d11 100644
--- a/lib/proxy/log_buffer/decorator.rb
+++ b/lib/proxy/log_buffer/decorator.rb
@@ -7,6 +7,8 @@ module Proxy::LogBuffer
       @@instance ||= new(::Proxy::LoggerFactory.logger, ::Proxy::LoggerFactory.log_file)
     end

+    attr_accessor :formatter
+
     def initialize(logger, log_file, buffer = Proxy::LogBuffer::Buffer.instance)
       @logger = logger
       @buffer = buffer
@@ -28,17 +30,18 @@ module Proxy::LogBuffer
     end

     def add(severity, message = nil, progname = nil, backtrace = nil)
+      severity ||= UNKNOWN
+      if message.nil?
+        if block_given?
+          message = yield
+        else
+          message = progname
+        end
+      end
+      message = formatter.call(severity, Time.now.utc, progname, message) if formatter
+      return if message == ''
       @mutex.synchronize do
         handle_log_rolling if @roll_log
-        severity ||= UNKNOWN
-        if message.nil?
-          if block_given?
-            message = yield
-          else
-            message = progname
-          end
-        end
-        return if message == ''
         # add to the logger first
         @logger.add(severity, message)
         @logger.add(::Logger::Severity::DEBUG, backtrace) if backtrace
-- 
2.17.2

#6 Updated by Lukas Zapletal 6 months ago

  • Status changed from New to Closed

Also available in: Atom PDF