daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top