Skip to content

Instantly share code, notes, and snippets.

@ruckus
Created January 12, 2010 01:21
Show Gist options
  • Save ruckus/274789 to your computer and use it in GitHub Desktop.
Save ruckus/274789 to your computer and use it in GitHub Desktop.
module ActiveSupport
class BufferedLogger
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
# If a newline is necessary then create a new message ending with a newline.
# Ensures that the original message is not mutated.
message = "#{message} (pid:#{$$})\n" unless message[-1] == ?\n
buffer << message
auto_flush
message
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment