winton's lilypad at master - GitHub
Lilypad
Hoptoad notifier for Rack-based frameworks.
Install
sudo gem install lilypad --source http://gemcutter.orgRails
config/environment.rb
require 'rack/lilypad' Rails::Initializer.run do |config| config.middleware.insert_after(ActionController::Failsafe, Rack::Lilypad, 'hoptoad_api_key_goes_here') endapp/controllers/application_controller.rb:
class ApplicationController < ActionController::Base def rescue_action(exception) super ENV['RACK_ENV'] = ENV['RAILS_ENV'] request.env['rack.lilypad.component'] = params[:controller] request.env['rack.lilypad.action'] = params[:action] raise exception end endSinatra
require 'rack/lilypad' class MyApp < Sinatra::Application enable :raise_errors # not necessary for Sinatra::Base use Rack::Lilypad, 'hoptoad_api_key_goes_here' endFilters
Don't send certain environment variables to Hoptoad.
use Rack::Lilypad, 'hoptoad_api_key_goes_here' do |hoptoad| hoptoad.filters << %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK) endDirect Access
Send exceptions to Hoptoad from a rescue block.
begin raise 'Test' rescue Exception => e Rack::Lilypad.notify(e) endLog
See what you are sending and receiving from Hoptoad.
use Rack::Lilypad, 'hoptoad_api_key_goes_here' do |hoptoad| hoptoad.log = '/var/www/log/hoptoad.log' endCompatibility
Tested with Ruby 1.8.6, 1.8.7, and 1.9.1.
Thanks
Lilypad wouldn't have happened without rack_hoptoad, toadhopper, Builder, and Nokogiri.
via github.com
Interesting little code component to move down to the Rack layer.