File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,18 @@ class Client
16
16
# GraphQL::Client::LogSubscriber.attach_to :graphql
17
17
#
18
18
class LogSubscriber < ActiveSupport ::LogSubscriber
19
+ SHOULD_USE_KWARGS = private_instance_methods . include? ( :mode_from )
20
+
19
21
def query ( event )
20
22
logger . info do
21
23
name = event . payload [ :operation_name ] . gsub ( "__" , "::" )
22
24
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
24
31
end
25
32
26
33
logger . debug do
@@ -32,7 +39,12 @@ def error(event)
32
39
logger . error do
33
40
name = event . payload [ :operation_name ] . gsub ( "__" , "::" )
34
41
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
36
48
end
37
49
end
38
50
end
You can’t perform that action at this time.
0 commit comments