Rails logger doesn't log nil, Ruby logger does

Is there some reason that the Rails logger doesn’t log nil as the string
“nil”, like the Ruby logger does? It is a bit confusing.

Ruby example:

$ cat log.rb
require ‘logger’

logger = Logger.new(STDOUT)

logger.info “test”
logger.info true
logger.info nil
logger.info “end test”

$ ruby log.rb
I, [2006-11-15T16:45:00.348262 #2058] INFO – : test
I, [2006-11-15T16:45:00.348815 #2058] INFO – : true
I, [2006-11-15T16:45:00.348917 #2058] INFO – : nil
I, [2006-11-15T16:45:00.349006 #2058] INFO – : end test

Rails 1.1.6 example:

class AboutController < ApplicationController

def home
logger.info “test”
logger.info true
logger.info nil
logger.info “end test”
end

end

Processing AboutController#home (for 127.0.0.1 at 2006-11-15 16:46:54)
[GET]
Session ID: 36e54d45b4ccb93b8d70d1a243526682
Parameters: {“action”=>“home”, “controller”=>“about”}
test
true

end test
Rendering about/home
Completed in 0.00238 (419 reqs/sec) | Rendering: 0.00092 (38%) | 200 OK
[http://

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs