diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index 2112e0899..5f70f38d0 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -1,3 +1,5 @@ +require "thread" + require "log4r" require "vagrant/util/safe_puts" @@ -53,6 +55,12 @@ module Vagrant class Basic < Interface include Util::SafePuts + def initialize + super + + @lock = Mutex.new + end + # Use some light meta-programming to create the various methods to # output text to the UI. These all delegate the real functionality # to `say`. @@ -123,9 +131,12 @@ module Vagrant # to based on the type of the message channel = type == :error || opts[:channel] == :error ? $stderr : $stdout - # Output! - safe_puts(format_message(type, message, opts), - :io => channel, :printer => printer) + # Output! We wrap this in a lock so that it safely outputs only + # one line at a time. + @lock.synchronize do + safe_puts(format_message(type, message, opts), + :io => channel, :printer => printer) + end end def scope(scope_name)