Class: PaulBunyan::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- PaulBunyan::LogSubscriber
- Defined in:
- lib/paul_bunyan/railtie/log_subscriber.rb
Constant Summary collapse
- ACTION_PAYLOAD_KEYS =
Handle the process_action event in the action_controller namespace
We’re using this to capture the vast majority of our info that goes into the log line
[:method, :controller, :action, :format, :path, :status, :view_runtime, :db_runtime]
Class Attribute Summary collapse
-
.action_controller_events ⇒ Object
readonly
Returns the value of attribute action_controller_events.
-
.action_view_events ⇒ Object
readonly
Returns the value of attribute action_view_events.
Class Method Summary collapse
-
.event_patterns ⇒ Object
Build an array of event patterns from the action_controller_events set for use in finding subscriptions we should add and ones we should remove from the default subscribers.
-
.subscribe_to_events(notifier = ActiveSupport::Notifications) ⇒ Object
Subscribe to the events we’ve registered using action_controller_event.
Instance Method Summary collapse
Class Attribute Details
.action_controller_events ⇒ Object (readonly)
Returns the value of attribute action_controller_events.
39 40 41 |
# File 'lib/paul_bunyan/railtie/log_subscriber.rb', line 39 def action_controller_events @action_controller_events end |
.action_view_events ⇒ Object (readonly)
Returns the value of attribute action_view_events.
39 40 41 |
# File 'lib/paul_bunyan/railtie/log_subscriber.rb', line 39 def action_view_events @action_view_events end |
Class Method Details
.event_patterns ⇒ Object
Build an array of event patterns from the action_controller_events set for use in finding subscriptions we should add and ones we should remove from the default subscribers
56 57 58 59 |
# File 'lib/paul_bunyan/railtie/log_subscriber.rb', line 56 def self.event_patterns action_controller_events.map{ |event| "#{event}.action_controller" } + action_view_events.map { |event| "#{event}.action_view" } end |
.subscribe_to_events(notifier = ActiveSupport::Notifications) ⇒ Object
Subscribe to the events we’ve registered using action_controller_event
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/paul_bunyan/railtie/log_subscriber.rb', line 62 def self.subscribe_to_events(notifier = ActiveSupport::Notifications) subscriber = new notifier = notifier subscribers << subscriber event_patterns.each do |pattern| if Rails::VERSION::MAJOR >= 6 subscriber.patterns[pattern] = notifier.subscribe(pattern, subscriber) else subscriber.patterns << pattern notifier.subscribe(pattern, subscriber) end end end |
Instance Method Details
#logger ⇒ Object
134 135 136 |
# File 'lib/paul_bunyan/railtie/log_subscriber.rb', line 134 def logger PaulBunyan.logger end |