Permalink
Browse files

Wrap the buffer in the mutex as well.

  • Loading branch information...
Scott Gonyea
Scott Gonyea committed Jul 6, 2012
1 parent 83b39a7 commit 13f466246a7538f23468a3704652c78b4567ae69
Showing with 5 additions and 3 deletions.
  1. +5 −3 padrino-core/lib/padrino-core/logger.rb
@@ -255,7 +255,7 @@ def stylized_level(level)
}
Config.merge!(PADRINO_LOGGER) if PADRINO_LOGGER
@@log_mutex = Mutex.new
@@mutex = Mutex.new
def self.logger
@@logger || setup!
end
@@ -336,7 +336,7 @@ def initialize(options={})
#
def flush
return unless @buffer.size > 0
@@log_mutex.synchronize do
@@mutex.synchronize do
@log.write(@buffer.slice!(0..-1).join(''))
end
end
@@ -368,7 +368,9 @@ def add(level, message = nil)
#
def <<(message = nil)
message << "\n" unless message[-1] == ?\n
@buffer << message
@@mutex.synchronize {
@buffer << message
}
flush if @auto_flush
message
end

0 comments on commit 13f4662

Please sign in to comment.