This project is archived and is in readonly mode.

#5141 ✓stale
Martijn Walraven

DeprecationProxy for RAILS_DEFAULT_LOGGER hides original warn method

Reported by Martijn Walraven | July 17th, 2010 @ 09:36 PM

In order to issue a deprecation warning when a method is invoked, railties/lib/rails/deprecation.rb sets RAILS_DEFAULT_LOGGER to a DeprecationProxy with Rails.logger as its target. But as DeprecationProxy defines its own warn method, RAILS_DEFAULT_LOGGER.warn fails with "ArgumentError: wrong number of arguments (1 for 3)" (because the number of arguments to the DeprecationProxy's warn method is 3).

The real fix is obviously not to use the now deprecated RAILS_DEFAULT_LOGGER, but I came across this problem in an external dependency. As a temporary hack I've set RAILS_DEFAULT_LOGGER to nil (as this disables logging for that library), but this is obviously not a working solution as it will mess with other code still depending on RAILS_DEFAULT_LOGGER (and also gives a "already initialized constant" warning). I will of course update the external dependency to use Rails.logger, but maybe this helps people encountering the same issue in other code.

So to summarize: RAILS_DEFAULT_LOGGER is deprecated and will be removed in a next version, but RAILS_DEFAULT_LOGGER.warn doesn't work even now, so maybe it's best to consider it removed already.

Comments and changes to this ticket

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:35 PM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:35 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages