diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-25 16:41:46 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-25 16:41:46 +0000 |
commit | 6f0390c957d77d74ace3258fbeac5ae8a9a0b7b8 (patch) | |
tree | 4701ce6e51ad6522e7296413b7f920f69b8aa967 /activesupport | |
parent | 42d35472b278611f9eb804bbdbe4bbc60da09c68 (diff) | |
download | rails-6f0390c957d77d74ace3258fbeac5ae8a9a0b7b8.tar.gz rails-6f0390c957d77d74ace3258fbeac5ae8a9a0b7b8.tar.bz2 rails-6f0390c957d77d74ace3258fbeac5ae8a9a0b7b8.zip |
Add BufferedLogger#add #9667 [tomafro]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7634 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-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}? |