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.
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 to Refactor #25100: Replace Ruby logging stack with logging gem added
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.
- Related to Bug #25267: Provide Ruby logger API method formatter added
[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
- Status changed from New to Closed
Also available in: Atom
PDF