Skip to content

Commit

Permalink
Allow ActiveSupport::Cache logger to be silenced
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jul 17, 2008
1 parent 94cf667 commit 0eef4e5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions activesupport/lib/active_support/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0eef4e5

Please sign in to comment.