Debug Rails (send to logger msg)

Action Pack provides a logger. Have a look to ri Logger:
you can use: logger.info('French cheese rocks'), logger.fatal('Django
sucks'), ... Those are writtent in log/*.log

You can also use breakpoints (ruby script/breakpointer) for debugging.

I did what you wrote, but I cannot find the output anywhere on the
screen :S any other easy way to debug my web application? please :slight_smile:

If you're running in development mode, the output will be written to
log/development.log. I tend to leave a terminal open running 'tail -f
log/development.log'.

Because all output is rendered through a View, it's not trivial to do
debug writes into the HTML itself, like you would in PHP, but the
logfile is a better approach anyway.

Gwyn.

You can use @debug(params) for instance.

A ugly hack would be:
logger.warn('poy!') in the controller

File.read("#{RAILS_ROOT}/log/development.log") in the view :confused:

But why debug in the view? Just use breakpoints.

I did what you wrote, but I cannot find the output anywhere on the
screen :S any other easy way to debug my web application? please :slight_smile:

└─(22:30:%)── ruby script/console

logger = Logger.new('log/development.log')

=> #<Logger:0xb69fa4dc @progname=nil, @level=0,
@logdev=#<Logger::LogDevice:0xb69fa48c @shift_age=0,
@filename="log/development.log",
@mutex=#<Logger::LogDevice::LogDeviceMutex:0xb69fa464
@mon_entering_queue=[], @mon_count=0, @mon_owner=nil,
@mon_waiting_queue=[]>, @dev=#<File:log/development.log>,
@shift_size=1048576>, @formatter=nil,
@default_formatter=#<Logger::Formatter:0xb69fa4b4 @datetime_format=nil>>

logger.warn('WTF?!')

=> true

exit

└─(1:22:31:%)── tail -1 log/development.log
WTF?!

Hope that helps.

Use mTail.
http://ophilipp.free.fr/op_tail.htm

Free. For windows.

-- Wes

I guess PowerShell have a tail cmd.