Skip to content

Commit

Permalink
Merge pull request #11486 from wolframarnold/3-2-stable_fix_respond_t…
Browse files Browse the repository at this point in the history
…o_missing_in_tagged_loggging

3-2-stable patch: Add respond_to_missing? in TaggedLoggging
  • Loading branch information
rafaelfranca committed Jul 18, 2013
2 parents 39441f7 + 803008e commit ed19c02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions activesupport/CHANGELOG.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@


*Andrew White* *Andrew White*


* Add respond_to_missing? for TaggedLogging which is best practice when overriding method_missing. This permits
wrapping TaggedLogging by another log abstraction such as em-logger.

*Wolfram Arnold*


## Rails 3.2.13 (Mar 18, 2013) ## ## Rails 3.2.13 (Mar 18, 2013) ##


Expand Down
4 changes: 4 additions & 0 deletions activesupport/lib/active_support/tagged_logging.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def method_missing(method, *args)
@logger.send(method, *args) @logger.send(method, *args)
end end


def respond_to_missing?(*args)
@logger.respond_to? *args
end

private private
def tags_text def tags_text
tags = current_tags tags = current_tags
Expand Down
4 changes: 4 additions & 0 deletions activesupport/test/tagged_logging_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def add(severity, message = nil, progname = nil, &block)
assert_equal "[BCX] Funky time\n", @output.string assert_equal "[BCX] Funky time\n", @output.string
end end


test "correctly answers responds_to_missing? for methods on logger instance" do
assert @logger.respond_to?(:debug?)
end

test "tagged once with blank and nil" do test "tagged once with blank and nil" do
@logger.tagged(nil, "", "New") { @logger.info "Funky time" } @logger.tagged(nil, "", "New") { @logger.info "Funky time" }
assert_equal "[New] Funky time\n", @output.string assert_equal "[New] Funky time\n", @output.string
Expand Down

0 comments on commit ed19c02

Please sign in to comment.