Skip to content

Instantly share code, notes, and snippets.

@leobessa
Created October 19, 2010 21:47
Show Gist options
  • Save leobessa/635206 to your computer and use it in GitHub Desktop.
Save leobessa/635206 to your computer and use it in GitHub Desktop.
module SQLGrowler
class Subscriber < ActiveRecord::LogSubscriber
def sql(event)
super
g = Growl.new("localhost", "ruby-growl", ["ruby-growl Notification"], ["ruby-growl Notification"], nil)
g.notify('ruby-growl Notification',application_name,'%s (%.1fms) %s' % [event.payload[:name], event.duration, event.payload[:sql].squeeze(' ')],1,true)
end
def application_name
@application_name ||= Rails.application.class.parent_name
end
end
end
SQLGrowler::Subscriber.attach_to :active_record
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment