Skip to content
Browse files

use different logger for async notices

fix rake test task for async
closes #119
  • Loading branch information...
1 parent fb6673e commit a3a1a92d39b8229c8cb305a3c7c8503267d433ab @shime shime committed Sep 9, 2012
Showing with 19 additions and 8 deletions.
  1. +4 −7 lib/airbrake/configuration.rb
  2. +14 −0 lib/airbrake/rails3_tasks.rb
  3. +1 −1 lib/airbrake/railtie.rb
View
11 lib/airbrake/configuration.rb
@@ -251,13 +251,10 @@ def async(&block)
end
alias_method :async?, :async
- def async=(value)
- # use default GirlFriday-async for 'true' value
- @async = if value == true
- default_async_processor
- else
- value
- end
+ def async=(use_default_or_this)
+ @async = use_default_or_this == true ?
+ default_async_processor :
+ use_default_or_this
end
def js_api_key
View
14 lib/airbrake/rails3_tasks.rb
@@ -8,6 +8,18 @@
ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) :
Logger.new(STDOUT)
+ def wait_for_threads
+ # if using multiple threads, we have to wait for
+ # them to finish
+ if GirlFriday.status.empty?
+ Thread.list.each do |thread|
+ thread.join unless thread == Thread.current
+ end
+ else
+ GirlFriday.shutdown!
+ end
+ end
+
Rails.logger.level = Logger::DEBUG
Airbrake.configure(true) do |config|
config.logger = Rails.logger
@@ -80,5 +92,7 @@ class AirbrakeVerificationController < ApplicationController; end
env = Rack::MockRequest.env_for("/verify")
Rails.application.call(env)
+
+ wait_for_threads
end
end
View
2 lib/airbrake/railtie.rb
@@ -15,7 +15,7 @@ class Railtie < ::Rails::Railtie
config.after_initialize do
Airbrake.configure(true) do |config|
- config.logger ||= ::Rails.logger
+ config.logger ||= config.async? ? ::Logger.new(STDERR) : ::Rails.logger
config.environment_name ||= ::Rails.env
config.project_root ||= ::Rails.root
config.framework = "Rails: #{::Rails::VERSION::STRING}"

0 comments on commit a3a1a92

Please sign in to comment.
Something went wrong with that request. Please try again.