Skip to content

Commit

Permalink
Wrap the buffer in the mutex as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Gonyea committed Jul 6, 2012
1 parent 83b39a7 commit 13f4662
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions padrino-core/lib/padrino-core/logger.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 13f4662

Please sign in to comment.