Guest User

Untitled

a guest
Jun 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. require 'active_support/log_subscriber'
  2.  
  3. module ActiveStorage
  4. class LogSubscriber < ActiveSupport::LogSubscriber
  5. def service_upload(event)
  6. message = event.payload[:something]
  7. info event, color(message, GREEN)
  8. end
  9. end
  10. end
  11.  
  12. ActiveStorage::LogSubscriber.attach_to :active_storage
  13.  
  14. module ActiveStorage
  15. class Service
  16. def upload
  17. instrument :upload, key: key, checksum: checksum
  18. end
  19.  
  20. private
  21. def instrument(operation, payload = {}, &block)
  22. ActiveSupport::Notifications.instrument "service_#{operation}.active_storage", payload
  23. end
  24. end
  25. end
Add Comment
Please, Sign In to add comment