Bug #25239
closedundefined method 'formatter=' for Logging::RootLogger when running SPDC inside smart-proxy
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
Updated by Adam Ruzicka about 6 years ago
- Related to Refactor #25100: Replace Ruby logging stack with logging gem added
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?
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.
Updated by Lukas Zapletal about 6 years ago
- Related to Bug #25267: Provide Ruby logger API method formatter added
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
Updated by Lukas Zapletal almost 6 years ago
- Status changed from New to Closed
Applied in changeset foreman_proxy_dynflow|2b6ccc2cfe8274ab7f01efc3114d8b6e6c6003c2.