make sure log output isn't messed when performing concurrent tasks

This commit is contained in:
Laurent Sansonetti
2012-01-03 11:21:17 +01:00
parent a5d426821d
commit 0bedf44f15

View File

@@ -35,8 +35,12 @@ module Motion; module Project
end
def log(what, msg)
what = "\e[1m" + what.rjust(10) + "\e[0m" # bold
$stderr.puts what + ' ' + msg
@print_mutex ||= Mutex.new
# Because this method can be called concurrently, we don't want to mess any output.
@print_mutex.synchronize do
what = "\e[1m" + what.rjust(10) + "\e[0m" # bold
$stderr.puts what + ' ' + msg
end
end
def warn(msg)