Permalink
Browse files

Allow ActiveSupport::Cache logger to be silenced

  • Loading branch information...
1 parent 94cf667 commit 0eef4e554db9b1af47305f5a8c51c90c15ac6c04 @josh josh committed Jul 17, 2008
Showing with 6 additions and 2 deletions.
  1. +6 −2 activesupport/lib/active_support/cache.rb
@@ -36,14 +36,18 @@ def self.expand_cache_key(key, namespace = nil)
expanded_cache_key
end
-
class Store
cattr_accessor :logger
def threadsafe!
extend ThreadSafety
end
+ def silence!
+ @silence = true
+ self
+ end
+
# Pass <tt>:force => true</tt> to force a cache miss.
def fetch(key, options = {})
@logger_off = true
@@ -108,7 +112,7 @@ def decrement(key, amount = 1)
private
def log(operation, key, options)
- logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@logger_off
+ logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@silence && !@logger_off
end
end

0 comments on commit 0eef4e5

Please sign in to comment.