Skip to content

Commit

Permalink
Forward all methods to delayed log
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Sep 17, 2009
1 parent 6be6fae commit 23e72d4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions actionpack/lib/abstract_controller/logger.rb
Expand Up @@ -11,15 +11,17 @@ module Logger
# just discard the String if the log level is too low. # just discard the String if the log level is too low.
# #
# TODO: Require that Rails loggers accept a block. # TODO: Require that Rails loggers accept a block.
class DelayedLog class DelayedLog < ActiveSupport::BasicObject
def initialize(&blk) def initialize(&block)
@blk = blk @str, @block = nil, block
end end


def to_s def method_missing(*args, &block)
@blk.call unless @str
@str, @block = @block.call, nil
end
@str.send(*args, &block)
end end
alias to_str to_s
end end


included do included do
Expand Down

0 comments on commit 23e72d4

Please sign in to comment.