Class: DebugLogging::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- DebugLogging::LogSubscriber
- 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 Attribute Summary collapse
-
.event ⇒ Object
Returns the value of attribute event.
Class Method Summary collapse
Methods included from ArgumentPrinter
debug_benchmark_to_s, debug_event_name_to_s, debug_event_time_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
Class Attribute Details
.event ⇒ Object
Returns the value of attribute event.
10 11 12 |
# File 'lib/debug_logging/log_subscriber.rb', line 10 def event @event end |
Class Method Details
.event_to_format_options(event) ⇒ Hash
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/debug_logging/log_subscriber.rb', line 28 def self.(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
16 17 18 19 20 21 22 23 24 |
# File 'lib/debug_logging/log_subscriber.rb', line 16 def self.log_event(event) @event = event if event.payload && event.payload[:exception_object] exception = event.payload[:exception_object] "#{event.name} [ERROR] : \n#{exception.class} : #{exception.}\n" + exception.backtrace.join("\n") else format(EVENT_FORMAT_STRING, (event)) end end |