Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Debugging output on development log #207

Closed
cemeng opened this Issue May 3, 2012 · 6 comments

Comments

Projects
None yet
6 participants

cemeng commented May 3, 2012

Hi all,

I am running Dalli 2.0.3 on our Rails 3.2.3 project. I've noticed that rails development.log is cluttered by cache operation messages, for instance:

Cache read: jobs/114141-20120226183819 ({:expires_in=>3 days})
Cache fetch_hit: jobs/114141-20120226183819 ({:expires_in=>3 days})

I had a look around the code and this logger call from lib/active_support/cache/dalli_store.rb line 204:

      def log(operation, key, options=nil)
        return unless logger && logger.debug?
        logger.debug("Cache #{operation}: #{key}#{options.blank? ? "" : " (#{options.inspect})"}")
      end

Not a big deal, but is there a setting to use to silence the output?
Or is it something that might be included in the future release?

Some more information, the logger here is ActiveSupport::TaggedLogging.

Also this might be useful, in activesupport/lib/activesupport/cache.rb - the log operation has silence option:

        def log(operation, key, options = nil)
          return unless logger && logger.debug? && !silence?
          logger.debug("Cache #{operation}: #{key}#{options.blank? ? "" : " (#{options.inspect})"}")
        end

Thanks for your work!

Felix

Collaborator

mperham commented May 3, 2012

I'm not sure why you are seeing so much logging but I added the silence! method so maybe that will fix the chatty logging.

@mperham mperham closed this May 3, 2012

cemeng commented May 3, 2012

Thanks Mike - that works for us.

I've created an initializers for our Rails project with the following code:

Rails.cache.silence!

And that does it.

catsby commented Aug 31, 2012

How can I mute/silence Dalli outside of Rails? I'm unsure where to call silence!

I have an app using dalli 2.5 and having an initializer with Rails.cache.silence! does not appear to actually silence stuff :(

silence! worked for me with dalli 2.1.0 and rails 3.2.11

I'm finding the same issue with dalli 2.7.2 and rails 3.2.18. Have tried:

Rails.cache.silence!
Rails.cache.mute { Rails.cache.read(:key) }

jvendetti added a commit to ncbo/bioportal_web_ui that referenced this issue Oct 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment