From 1cf8f10ccf2ed1fabe79935a3f60fc2159cf9c02 Mon Sep 17 00:00:00 2001 From: Yuki Nishijima Date: Mon, 5 Feb 2024 15:01:04 +0900 Subject: [PATCH] Address the deprecation warnings from the logger This addresses the deprecation warning below: DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. ). --- lib/graphql/client/log_subscriber.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/graphql/client/log_subscriber.rb b/lib/graphql/client/log_subscriber.rb index 512d0cf8..1a3bd225 100644 --- a/lib/graphql/client/log_subscriber.rb +++ b/lib/graphql/client/log_subscriber.rb @@ -16,11 +16,18 @@ class Client # GraphQL::Client::LogSubscriber.attach_to :graphql # class LogSubscriber < ActiveSupport::LogSubscriber + SHOULD_USE_KWARGS = private_instance_methods.include?(:mode_from) + def query(event) logger.info do name = event.payload[:operation_name].gsub("__", "::") type = event.payload[:operation_type].upcase - color("#{name} #{type} (#{event.duration.round(1)}ms)", nil, true) + + if SHOULD_USE_KWARGS + color("#{name} #{type} (#{event.duration.round(1)}ms)", nil, bold: true) + else + color("#{name} #{type} (#{event.duration.round(1)}ms)", nil, true) + end end logger.debug do @@ -32,7 +39,12 @@ def error(event) logger.error do name = event.payload[:operation_name].gsub("__", "::") message = event.payload[:message] - color("#{name} ERROR: #{message}", nil, true) + + if SHOULD_USE_KWARGS + color("#{name} ERROR: #{message}", nil, bold: true) + else + color("#{name} ERROR: #{message}", nil, true) + end end end end