Class: Fino::Rails::Instrumentation::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Fino::Rails::Instrumentation::LogSubscriber
- Defined in:
- lib/fino/rails/instrumentation/log_subscriber.rb
Instance Method Summary collapse
- #adapter(event) ⇒ Object
- #cache(event) ⇒ Object
-
#log_instrumentation_event(event) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Instance Method Details
#adapter(event) ⇒ Object
8 9 10 |
# File 'lib/fino/rails/instrumentation/log_subscriber.rb', line 8 def adapter(event) log_instrumentation_event(event) end |
#cache(event) ⇒ Object
12 13 14 |
# File 'lib/fino/rails/instrumentation/log_subscriber.rb', line 12 def cache(event) log_instrumentation_event(event) end |
#log_instrumentation_event(event) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fino/rails/instrumentation/log_subscriber.rb', line 16 def log_instrumentation_event(event) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength return unless logger.debug? payload = event.payload method_name = payload[:method_name] class_name = payload[:class_name] key = payload[:key] duration = event.duration name = color("#{class_name} #{method_name.to_s.upcase}", :yellow, bold: true) duration_text = color("(#{duration.round(1)}ms)", nil) = " #{name} #{duration_text}" += color(" key=#{key}", :blue, bold: true) if key && !key.to_s.empty? debug() end |