lib/airbrake/rails3_tasks.rb in airbrake-3.1.6 vs lib/airbrake/rails3_tasks.rb in airbrake-3.1.7
- old
+ new
@@ -18,24 +18,32 @@
else
GirlFriday.shutdown!
end
end
+ # Sets up verbose logging
Rails.logger.level = Logger::DEBUG
Airbrake.configure(true) do |config|
config.logger = Rails.logger
end
+ # Override Rails exception middleware, so we stop cluttering STDOUT
+ class ActionDispatch::DebugExceptions; def call(env); @app.call(env); end; end
+ class ActionDispatch::ShowExceptions; def call(env); @app.call(env); end; end
+
require './app/controllers/application_controller'
class AirbrakeTestingException < RuntimeError; end
+ # Checks if api_key is set
unless Airbrake.configuration.api_key
puts "Airbrake needs an API key configured! Check the README to see how to add it."
exit
end
+ # Enables Airbrake reporting on all environments,
+ # so we don't have to worry about invoking the task in production
Airbrake.configuration.development_environments = []
puts "Configuration:"
Airbrake.configuration.to_hash.each do |key, value|
puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
@@ -50,47 +58,34 @@
class ApplicationController
# This is to bypass any filters that may prevent access to the action.
prepend_before_filter :test_airbrake
def test_airbrake
puts "Raising '#{exception_class.name}' to simulate application failure."
- raise exception_class.new, 'Testing airbrake via "rake airbrake:test". If you can see this, it works.'
+ raise exception_class.new, "\nTesting airbrake via \"rake airbrake:test\"."\
+ " If you can see this, it works."
end
- # def rescue_action(exception)
- # rescue_action_in_public exception
- # end
-
# Ensure we actually have an action to go to.
def verify; end
- # def consider_all_requests_local
- # false
- # end
-
- # def local_request?
- # false
- # end
-
def exception_class
exception_name = ENV['EXCEPTION'] || "AirbrakeTestingException"
Object.const_get(exception_name)
rescue
Object.const_set(exception_name, Class.new(Exception))
end
-
- def logger
- nil
- end
end
- class AirbrakeVerificationController < ApplicationController; end
- Rails.application.routes_reloader.execute_if_updated
Rails.application.routes.draw do
- match 'verify' => 'application#verify', :as => 'verify'
+ get 'verify' => 'application#verify', :as => 'verify'
end
puts 'Processing request.'
- env = Rack::MockRequest.env_for("/verify")
+
+ config = Rails.application.config
+ protocol = (config.respond_to?(:force_ssl) && config.force_ssl) ? 'https' : 'http'
+
+ env = Rack::MockRequest.env_for("#{protocol}://www.example.com/verify")
Rails.application.call(env)
wait_for_threads
end