ResourceLogger doesn't need to be thread-safe. Vagrant is not multi-threaded.
This commit is contained in:
parent
aaa09749e4
commit
050677b359
|
@ -1,5 +1,3 @@
|
|||
require 'thread'
|
||||
|
||||
module Vagrant
|
||||
module Util
|
||||
# Represents a logger for a specific resource within Vagrant. Each
|
||||
|
@ -9,11 +7,8 @@ module Vagrant
|
|||
#
|
||||
# [resource] message
|
||||
#
|
||||
# This class is thread safe. The backing class which actually does
|
||||
# all the logging IO is protected.
|
||||
class ResourceLogger
|
||||
@@singleton_logger = nil
|
||||
@@writer_lock = Mutex.new
|
||||
|
||||
# The resource which this logger represents.
|
||||
attr_reader :resource
|
||||
|
@ -53,11 +48,9 @@ module Vagrant
|
|||
|
||||
[:debug, :info, :error, :fatal].each do |method|
|
||||
define_method(method) do |message|
|
||||
@@writer_lock.synchronize do
|
||||
logger.send(method, "[#{resource}] #{message}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue