From f654d658f2dab5f4dcc42b2d0c308b4d806dc491 Mon Sep 17 00:00:00 2001 From: Avner Cohen Date: Tue, 13 Aug 2013 22:22:56 +0300 Subject: When logging Cache key, in debug mode, also log namespace, to create the full key that actually used by the underline cache implementation --- activesupport/lib/active_support/cache.rb | 2 +- activesupport/test/caching_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 837974bc85..1ed1ded320 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -533,7 +533,7 @@ module ActiveSupport end def instrument(operation, key, options = nil) - log { "Cache #{operation}: #{key}#{options.blank? ? "" : " (#{options.inspect})"}" } + log { "Cache #{operation}: #{namespaced_key(key, options)}#{options.blank? ? "" : " (#{options.inspect})"}" } payload = { :key => key } payload.merge!(options) if options.is_a?(Hash) diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 8e22d4ed2f..322d058696 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -1045,6 +1045,19 @@ class CacheStoreLoggerTest < ActiveSupport::TestCase assert @buffer.string.present? end + def test_log_with_string_namespace + @cache.fetch('foo', {namespace: 'string_namespace'}) { 'bar' } + assert_match %r{string_namespace:foo}, @buffer.string + end + + def test_log_with_proc_namespace + proc = Proc.new do + "proc_namespace" + end + @cache.fetch('foo', {:namespace => proc}) { 'bar' } + assert_match %r{proc_namespace:foo}, @buffer.string + end + def test_mute_logging @cache.mute { @cache.fetch('foo') { 'bar' } } assert @buffer.string.blank? -- cgit v1.2.3