From 4f22d38ab6fd8946bd963f37f0efbe17e9e37628 Mon Sep 17 00:00:00 2001 From: Doug Edey Date: Fri, 3 Nov 2023 15:41:14 -0400 Subject: [PATCH] For Rails 7.1 or above, use the named bold param --- lib/standby/active_record/log_subscriber.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/standby/active_record/log_subscriber.rb b/lib/standby/active_record/log_subscriber.rb index 7cfe1e1..3e1faf4 100644 --- a/lib/standby/active_record/log_subscriber.rb +++ b/lib/standby/active_record/log_subscriber.rb @@ -4,9 +4,15 @@ class LogSubscriber alias_method :debug_without_standby, :debug def debug(msg) - db = Standby.disabled ? "" : color("[#{Thread.current[:_standby] || "primary"}]", ActiveSupport::LogSubscriber::GREEN, true) + db = Standby.disabled ? "" : log_header debug_without_standby(db + msg) end + def log_header + if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}".to_f > 7.1 + color("[#{Thread.current[:_standby] || "primary"}]", ActiveSupport::LogSubscriber::GREEN, bold: true) + else + color("[#{Thread.current[:_standby] || "primary"}]", ActiveSupport::LogSubscriber::GREEN, true) + end end end