<?php
/**
 * A class for logging information to the firebug console.
 */
class log_writer_firebug extends log_filter
{
    ////////////////////////////////////////////////////////////////////////////
    // Construct and destruct functions.
    
    ////////////////////////////////////////////////////////////////////////////
    // Overload functions.

    ////////////////////////////////////////////////////////////////////////////
    // Interface functions.

    ////////////////////////////////////////////////////////////////////////////
    // Internal functions.
    
    /**
     * Writes a log message to the firebug console.
     *
     * @param string $message The message.
     * @param integer $priority The priority.
     * @param string $timestamp The date.
     * @return log_writer_firebug A fluent interface.
     */
    protected function _write($message, $priority, $timestamp)
    {
        $function = null;
        
        switch($priority)
        {
            case 1  :
            case 2  :
            case 3  :
            case 4  : $function = 'error'; break;
            case 5  : 
            case 6  : $function = 'warn';  break;
            case 7  : $function = 'info';  break;
            case 8  :
            default : $function = 'log';
        }
        
        FirePHP::getInstance(true)->$function($priority . '|' . $message, $timestamp);
        return $this;
    }
}
