Convert PHP code into Ruby!
RSS icon Email icon Home icon
  • error_log

    Posted on May 2nd, 2009 RubyLove No comments

    The error_log() function sends an error message to the web server’s error log, a TCP port or to a file (usually the web server’s error log).

    PHP

    error_log('My error message');
    // => My error message

    error_log() is probably one of the most common and convenient ways to debug PHP scripts, without having to install a full PHP debugger. As such, it is very popular with developers, often logging variables part way through a script, to see if the values are what they expect. Although Ruby doesn’t provide such a convenient global function, it does provide the Logger class which is much more powerful.

    Ruby

    require('Logger');
    Logger.new('/var/log/httpd/error.log').error('My error message');
    # => ERROR -- : My error message

    Leave a reply