Guest User

Untitled

a guest
Jun 18th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. module SQLGrowler
  2. class Subscriber < ActiveRecord::LogSubscriber
  3.  
  4. def sql(event)
  5. super
  6. g = Growl.new("localhost", "ruby-growl", ["ruby-growl Notification"], ["ruby-growl Notification"], nil)
  7. g.notify('ruby-growl Notification',application_name,'%s (%.1fms) %s' % [event.payload[:name], event.duration, event.payload[:sql].squeeze(' ')],1,true)
  8. end
  9.  
  10. def application_name
  11. @application_name ||= Rails.application.class.parent_name
  12. end
  13.  
  14. end
  15.  
  16. end
  17.  
  18. SQLGrowler::Subscriber.attach_to :active_record
Add Comment
Please, Sign In to add comment