Project

General

Profile

Actions

Bug #25239

closed

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

Added by Adam Ruzicka about 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Proxy plugin
Target version:
-
Difficulty:
Triaged:
No
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 2 (0 open2 closed)

Related to Smart Proxy - Refactor #25100: Replace Ruby logging stack with logging gemClosedLukas ZapletalActions
Related to Smart Proxy - Bug #25267: Provide Ruby logger API method formatterClosedLukas ZapletalActions
Actions #1

Updated by Adam Ruzicka about 6 years ago

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

Updated by Daniel Lobato Garcia about 6 years 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?

Actions #3

Updated by Lukas Zapletal about 6 years 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.

Actions #4

Updated by Lukas Zapletal about 6 years ago

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

Updated by Lukas Zapletal about 6 years 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
Actions #6

Updated by Lukas Zapletal almost 6 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF