If you need to log to a file you can use Ruby's Logger
class:
require 'logger'
log = Logger.new('log/mylog.log')
log.info 'Some information'
log.debug 'Debugging hints'
log.error StandardError.new('Something went wrong')
Logger
does a number of things well:
If you don't like the output format, you can define a custom formatter.
I haven't found a nice way to make Logger
auto-flush after every line, but there are hacks.
require 'logger'
log = Logger.new(STDOUT)
log.info 'Some information'