Forum: Ruby sending false to logger outputs nil?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Rob S. (Guest)
on 2006-06-08 01:14
(Received via mailing list)
Am I missing something?  Why would sending false to the logger just
output nil, instead of "false" to correspond to what sending true

According to the docs: "message can be any object, but it has to be
converted to a String in order to log it. Generally, inspect is used
if the given object is not a String. "

This just drove me crazy for a good half hour until I figured out what
was going on, as I was logging a complex statement that evaluated to a

irb(main):001:0> require 'logger'

=> true
irb(main):002:0> logger =
=> #<Logger:0x3307f0 @level=0, @progname=nil,
@logdev=#<Logger::LogDevice:0x3307a0 @dev=#<IO:0x1e9868>,
@shift_size=nil, @shift_age=nil, @filename=nil,
@mon_waiting_queue=[], @mon_entering_queue=[], @mon_count=0,
@mon_owner=nil>>, @formatter=nil,
@default_formatter=#<Logger::Formatter:0x3307c8 @datetime_format=nil>>

irb(main):003:0> logger.debug(true)
D, [2006-06-07T16:10:23.569265 #5516] DEBUG -- : true
=> true

irb(main):004:0> logger.debug(false)
D, [2006-06-07T16:10:26.721498 #5516] DEBUG -- : nil
=> true

I, [2006-06-07T16:10:59.451009 #5516]  INFO -- : nil
=> true

- Rob
This topic is locked and can not be replied to.