Skip to content
This repository
Browse code

Forward all methods to delayed log

  • Loading branch information...
commit 23e72d4cc8d879e4d3facac31f96643da48a8a27 1 parent 6be6fae
Joshua Peek josh authored

Showing 1 changed file with 8 additions and 6 deletions. Show diff stats Hide diff stats

  1. +8 6 actionpack/lib/abstract_controller/logger.rb
14 actionpack/lib/abstract_controller/logger.rb
@@ -11,15 +11,17 @@ module Logger
11 11 # just discard the String if the log level is too low.
12 12 #
13 13 # TODO: Require that Rails loggers accept a block.
14   - class DelayedLog
15   - def initialize(&blk)
16   - @blk = blk
  14 + class DelayedLog < ActiveSupport::BasicObject
  15 + def initialize(&block)
  16 + @str, @block = nil, block
17 17 end
18 18
19   - def to_s
20   - @blk.call
  19 + def method_missing(*args, &block)
  20 + unless @str
  21 + @str, @block = @block.call, nil
  22 + end
  23 + @str.send(*args, &block)
21 24 end
22   - alias to_str to_s
23 25 end
24 26
25 27 included do

0 comments on commit 23e72d4

Please sign in to comment.
Something went wrong with that request. Please try again.