Avoid locking in trap context

This commit is contained in:
Mitchell Hashimoto 2014-02-23 22:22:18 -08:00
parent 3324756e12
commit 8bb0094113
1 changed files with 8 additions and 1 deletions

View File

@ -34,7 +34,14 @@ module Vagrant
[:ask, :detail, :warn, :error, :info, :output, :success].each do |method|
define_method(method) do |message, *opts|
# Log normal console messages
@logger.info { "#{method}: #{message}" }
begin
@logger.info { "#{method}: #{message}" }
rescue ThreadError
# We're being called in a trap-context. Wrap in a thread.
Thread.new do
@logger.info { "#{method}: #{message}" }
end.join
end
end
end