Defect #18605

Wrong usage of logger.info to test log level

Added by Jérôme BATAILLE about 4 years ago. Updated about 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Code cleanup/refactoring
Target version:3.0.0
Resolution:Fixed Affected version:

Description

logger.info (instead of logger.info?) can trigger an error

Line 185 :

logger.info "time entry could not be updated: #{time_entry.errors.full_messages}" if logger && logger.info

replace by :

logger.info "time entry could not be updated: #{time_entry.errors.full_messages}" if logger && logger.info?

Associated revisions

Revision 13766
Added by Jean-Philippe Lang about 4 years ago

Use logger.info? (#18605).

History

#1 Updated by Jérôme BATAILLE about 4 years ago

Sorry I missed a closing pre Tag !

#2 Updated by Jean-Philippe Lang about 4 years ago

  • Description updated (diff)

Jérôme BATAILLE wrote:

logger.info (instead of logger.info?) can trigger an error

In which circumstances?

#3 Updated by Jérôme BATAILLE about 4 years ago

Jean-Philippe Lang wrote:

In which circumstances?

In fact it can't because nil is managed as the default value.

But logger.info always return true (http://www.ruby-doc.org/stdlib-2.0/libdoc/logger/rdoc/Logger.html#method-i-add), so you can't use logger.info to detect if info level is enabled.

#4 Updated by Jean-Philippe Lang about 4 years ago

  • Subject changed from Typo in app/controllers/timelog_controller.rb to Wrong usage of logger.info to test log level
  • Category changed from Time tracking to Code cleanup/refactoring
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 3.0.0
  • Resolution set to Fixed

Fixed in r13766 with another one, thanks.

#5 Updated by Jérôme BATAILLE about 4 years ago

Thanks a lot again ! :-)

Also available in: Atom PDF