16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/time_bandits/time_consumers/redis.rb', line 16
def request(event)
i = Redis.instance
i.time += event.duration
i.calls += 1
return unless logger.debug?
name = "%s (%.2fms)" % ["Redis", event.duration]
cmds = event.payload[:commands]
output = " #{name}"
cmds.each do |cmd, *args|
if args.present?
logged_args = args.map do |a|
case
when a.respond_to?(:inspect) then a.inspect
when a.respond_to?(:to_s) then a.to_s
else
klass = a.instance_exec { (class << self; self end).superclass }
"\#<#{klass}:#{a.__id__}>"
end
end
output << " [ #{cmd.to_s.upcase} #{logged_args.join(" ")} ]"
else
output << " [ #{cmd.to_s.upcase} ]"
end
end
debug output
end
|