From 14e7ff8d00ca0092c318066c5b180643f23e106a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 24 Jul 2010 00:29:46 -0700 Subject: [PATCH] Flush all log output and sleep a bit for NFS export warning [closes GH-119] --- lib/vagrant/hosts/bsd.rb | 4 ++++ lib/vagrant/hosts/linux.rb | 2 ++ lib/vagrant/util/plain_logger.rb | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/lib/vagrant/hosts/bsd.rb b/lib/vagrant/hosts/bsd.rb index 18933aaef..97069062f 100644 --- a/lib/vagrant/hosts/bsd.rb +++ b/lib/vagrant/hosts/bsd.rb @@ -23,7 +23,11 @@ module Vagrant :ip => ip, :folders => folders) + # The sleep ensures that the output is truly flushed before any `sudo` + # commands are issued. env.logger.info "Preparing to edit /etc/exports. Administrator priveleges will be required..." + sleep 0.5 + output.split("\n").each do |line| # This should only ask for administrative permission once, even # though its executed in multiple subshells. diff --git a/lib/vagrant/hosts/linux.rb b/lib/vagrant/hosts/linux.rb index 023c213f3..3f55aefd7 100644 --- a/lib/vagrant/hosts/linux.rb +++ b/lib/vagrant/hosts/linux.rb @@ -25,6 +25,8 @@ module Vagrant :folders => folders) env.logger.info "Preparing to edit /etc/exports. Administrator priveleges will be required..." + sleep 0.5 + output.split("\n").each do |line| # This should only ask for administrative permission once, even # though its executed in multiple subshells. diff --git a/lib/vagrant/util/plain_logger.rb b/lib/vagrant/util/plain_logger.rb index b3715b6d1..262b0c56e 100644 --- a/lib/vagrant/util/plain_logger.rb +++ b/lib/vagrant/util/plain_logger.rb @@ -3,6 +3,17 @@ module Vagrant # Subclass of the standard library logger which has no format on # its own. The message sent to the logger is outputted as-is. class PlainLogger < ::Logger + # This is the method which is called for all debug, info, error, + # etc. methods by the logger. This is overriden to verify that + # the output is always flushed. + # + # Logger by default syncs all log devices but this just verifies + # it is truly flushed. + def add(*args) + super + @logdev.dev.flush if @logdev + end + def format_message(level, time, progname, msg) # We do no formatting, its up to the user "#{msg}\n"