diff options
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/buffered_logger.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/buffered_logger.rb b/activesupport/lib/active_support/buffered_logger.rb index b28f4a5ad3..c646b43d96 100644 --- a/activesupport/lib/active_support/buffered_logger.rb +++ b/activesupport/lib/active_support/buffered_logger.rb @@ -49,14 +49,19 @@ module ActiveSupport end end + def add(severity, message = nil, progname = nil, &block) + return if @level > severity + message = message || (block && block.call) || progname + message << "\n" unless message[-1] == ?\n + @buffer << message + flush if auto_flushing + message + end + for severity in Severity.constants class_eval <<-EOT - def #{severity.downcase}(message) - return if @level > #{severity} - message << "\\n" unless message[-1] == ?\\n - @buffer << message - flush if auto_flushing - message + def #{severity.downcase}(message = nil, progname = nil, &block) + add(#{severity}, message, progname, &block) end def #{severity.downcase}? |