Skip to content

Commit b177b19

Browse files
authored
Merge pull request #10 from yuki24/rails-7-1-deprecation-warnings
Address the deprecation warnings from the logger
2 parents e850ae2 + 1cf8f10 commit b177b19

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/graphql/client/log_subscriber.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ class Client
1616
# GraphQL::Client::LogSubscriber.attach_to :graphql
1717
#
1818
class LogSubscriber < ActiveSupport::LogSubscriber
19+
SHOULD_USE_KWARGS = private_instance_methods.include?(:mode_from)
20+
1921
def query(event)
2022
logger.info do
2123
name = event.payload[:operation_name].gsub("__", "::")
2224
type = event.payload[:operation_type].upcase
23-
color("#{name} #{type} (#{event.duration.round(1)}ms)", nil, true)
25+
26+
if SHOULD_USE_KWARGS
27+
color("#{name} #{type} (#{event.duration.round(1)}ms)", nil, bold: true)
28+
else
29+
color("#{name} #{type} (#{event.duration.round(1)}ms)", nil, true)
30+
end
2431
end
2532

2633
logger.debug do
@@ -32,7 +39,12 @@ def error(event)
3239
logger.error do
3340
name = event.payload[:operation_name].gsub("__", "::")
3441
message = event.payload[:message]
35-
color("#{name} ERROR: #{message}", nil, true)
42+
43+
if SHOULD_USE_KWARGS
44+
color("#{name} ERROR: #{message}", nil, bold: true)
45+
else
46+
color("#{name} ERROR: #{message}", nil, true)
47+
end
3648
end
3749
end
3850
end

0 commit comments

Comments
 (0)