Skip to content

Loading…

3-2-stable patch: Add respond_to_missing? in TaggedLoggging #11486

Merged
merged 1 commit into from

5 participants

@wolframarnold

Added respond_to_missing? for TaggedLogging which is needed if another log abstracter wraps a TaggedLogging instance.
Implementing respond_to_missing? is also a Ruby best practice when overriding method_missing.

@wolframarnold wolframarnold Add respond_to_missing? for TaggedLogging which is needed if another …
…log abstracter wraps a TaggedLogging instance.

It's also best practice when overriding method_missing.
803008e
@rafaelfranca
Ruby on Rails member

Could you put the changelog entry on the top?

@rafaelfranca rafaelfranca merged commit ed19c02 into rails:3-2-stable

1 check failed

Details default The Travis CI build failed
@wolframarnold wolframarnold added a commit to wolframarnold/rails that referenced this pull request
@wolframarnold wolframarnold Update to pull request #11486:
Moved order of contibution in Changelog per Rafael's request
5bbfcae
@UncleGene

Rails does not support 1.8.7

Ruby on Rails member

@pftg : Actually, this is commit in on the 3-2-stable branch.

oh, I see, sorry!

Ruby on Rails member

No problem! Just a FYI. :wink:

Sorry I did not update here - patch is already merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2013
  1. @wolframarnold

    Add respond_to_missing? for TaggedLogging which is needed if another …

    wolframarnold committed
    …log abstracter wraps a TaggedLogging instance.
    
    It's also best practice when overriding method_missing.
View
4 activesupport/CHANGELOG.md
@@ -27,6 +27,10 @@
*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) ##
View
4 activesupport/lib/active_support/tagged_logging.rb
@@ -72,6 +72,10 @@ def method_missing(method, *args)
@logger.send(method, *args)
end
+ def respond_to_missing?(*args)
+ @logger.respond_to? *args
+ end
+
private
def tags_text
tags = current_tags
View
4 activesupport/test/tagged_logging_test.rb
@@ -66,6 +66,10 @@ def add(severity, message = nil, progname = nil, &block)
assert_equal "[BCX] Funky time\n", @output.string
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
@logger.tagged(nil, "", "New") { @logger.info "Funky time" }
assert_equal "[New] Funky time\n", @output.string
Something went wrong with that request. Please try again.