Skip to content

Commit

Permalink
use different logger for async notices
Browse files Browse the repository at this point in the history
fix rake test task for async
closes airbrake#119
  • Loading branch information
shime committed Sep 9, 2012
1 parent fb6673e commit a3a1a92
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
11 changes: 4 additions & 7 deletions lib/airbrake/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions lib/airbrake/rails3_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,5 +92,7 @@ class AirbrakeVerificationController < ApplicationController; end
env = Rack::MockRequest.env_for("/verify")

Rails.application.call(env)

wait_for_threads
end
end
2 changes: 1 addition & 1 deletion lib/airbrake/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit a3a1a92

Please sign in to comment.