Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

TaggedLogging doesn't delegate properly (breaks Logger#silence method) #4159

Closed
dolzenko opened this Issue · 2 comments

3 participants

@dolzenko

The latest RC added TaggedLogging which breaks the Logger#silence method which was used before to silence logger messages and is defined here https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/logger.rb#L43

(new Kernel#silence is delegated to instead). Illustration

rails new temp && cd temp && rails console
Rails.logger.silence {}
ArgumentError: wrong number of arguments (0 for 1)
        from /home/evgeniy/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc1/lib/active_support/core_ext/kernel/reporting.rb:68:in `capture'
        from (irb):1

Failing test

dolzenko/rails@c28e4c

So what should we do?

I've fixed that by making TaggedLogging inherit from BasicObject, tests pass, hopefully someone can review the fix below

dolzenko/rails@ad92e9

@TylerRick

Could someone tell me why this is deprecated?

Wouldn't you all rather read this code:

      logger.silence Logger::INFO do
        ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
      end

than this:

      begin
        orig_level, Rails.logger.level = Rails.logger.level, Logger::INFO
        ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
      ensure
        Rails.logger.level = orig_level
      end

? Or am I just strange like that?

(see also: http://stackoverflow.com/questions/9076635/rails-3-2-silence-logging-deprecation-warning)

@tenderlove
Owner

Calling silence isn't thread safe. If we make it thread safe, then all other threads must be synchronized during your silence execution.

@taavo taavo referenced this issue in dolzenko/silent-postgres
Open

silence is deprecated #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.