Class: DebugLogging::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- DebugLogging::LogSubscriber
show all
- Extended by:
- ArgumentPrinter
- Defined in:
- lib/debug_logging/log_subscriber.rb
Constant Summary
collapse
- EXCLUDE_FROM_PAYLOAD =
%i[debug_args config_proxy].freeze
- EVENT_FORMAT_STRING =
"%<name>s (%<duration>.3f secs) start=%<time>s end=%<end>s args=%<args>s payload=%<payload>s"
Class Method Summary
collapse
debug_args_to_s, debug_benchmark_to_s, debug_event_name_to_s, debug_event_time_to_s, debug_hash_key_to_s, debug_invocation_id_to_s, debug_invocation_to_s, debug_payload_to_s, debug_safe_proc, debug_signature_to_s, debug_time_to_s, debug_value_to_s
Class Method Details
.event ⇒ Object
10
11
12
|
# File 'lib/debug_logging/log_subscriber.rb', line 10
def event
@@event
end
|
.event=(value) ⇒ Object
14
15
16
|
# File 'lib/debug_logging/log_subscriber.rb', line 14
def event=(value)
@@event = value
end
|
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/debug_logging/log_subscriber.rb', line 30
def event_to_format_options(event)
args = event.payload[:debug_args]
config_proxy = event.payload[:config_proxy]
payload = event.payload.reject { |k, _| EXCLUDE_FROM_PAYLOAD.include?(k) }
{
name: event.name,
duration: Rational(event.duration, 1000).to_f,
time: debug_event_time_to_s(event.time),
end: debug_event_time_to_s(event.end),
args: debug_signature_to_s(args: args, config_proxy: config_proxy),
payload: debug_payload_to_s(payload: payload, config_proxy: config_proxy),
}
end
|
.log_event(event) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/debug_logging/log_subscriber.rb', line 18
def log_event(event)
self.event = event
if event.payload && event.payload[:exception_object]
exception = event.payload[:exception_object]
"#{event.name} [ERROR] : \n#{exception.class} : #{exception.message}\n" + exception.backtrace.join("\n")
else
format(EVENT_FORMAT_STRING, event_to_format_options(event))
end
end
|