Class: Toy::Instrumentation::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Toy::Instrumentation::LogSubscriber
- Defined in:
- lib/toy/instrumentation/log_subscriber.rb
Instance Method Summary collapse
- #create(event) ⇒ Object
- #destroy(event) ⇒ Object
- #key(event) ⇒ Object
- #log_event(action, event) ⇒ Object
- #read(event) ⇒ Object
- #read_multiple(event) ⇒ Object
- #update(event) ⇒ Object
Instance Method Details
#create(event) ⇒ Object
22 23 24 25 |
# File 'lib/toy/instrumentation/log_subscriber.rb', line 22 def create(event) return unless logger.debug? log_event :create, event end |
#destroy(event) ⇒ Object
32 33 34 35 |
# File 'lib/toy/instrumentation/log_subscriber.rb', line 32 def destroy(event) return unless logger.debug? log_event :destroy, event end |
#key(event) ⇒ Object
17 18 19 20 |
# File 'lib/toy/instrumentation/log_subscriber.rb', line 17 def key(event) return unless logger.debug? log_event :key, event end |
#log_event(action, event) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/toy/instrumentation/log_subscriber.rb', line 37 def log_event(action, event) id = event.payload[:id] model = event.payload[:model] name = '%s (%.1fms)' % ["#{model.name} #{action}", event.duration] debug " #{color(name, CYAN, true)} [ #{id.inspect} ]" end |
#read(event) ⇒ Object
7 8 9 10 |
# File 'lib/toy/instrumentation/log_subscriber.rb', line 7 def read(event) return unless logger.debug? log_event :read, event end |
#read_multiple(event) ⇒ Object
12 13 14 15 |
# File 'lib/toy/instrumentation/log_subscriber.rb', line 12 def read_multiple(event) return unless logger.debug? log_event :read_multiple, event end |
#update(event) ⇒ Object
27 28 29 30 |
# File 'lib/toy/instrumentation/log_subscriber.rb', line 27 def update(event) return unless logger.debug? log_event :update, event end |