<?php
namespace Monolog\Handler;

class jFirebugHandler extends AbstractProcessingHandler
{
	protected function write(array $record)
	{
		if( function_exists( 'fb' ) )
		{
			switch( $record['level_name'] )
			{
				case 'DEBUG':
					$l = 'LOG';
					break;
				case 'INFO':
				case 'NOTICE':
					$l = 'INFO';
					break;
				case 'WARNING':
					$l = 'WARN';
					break;
				case 'ERROR':
				case 'CRITICAL':
				case 'ALERT':
				case 'EMERGENCY':
					$l = 'ERROR';
					break;
				default:
					$l = 'LOG';
					break;
			}
			if( ! empty( $record['context'] ) )
			{
				fb( $record['context'], $record['message'], $l );
			}
			else
			{
				fb( $record['message'], $l );
			}
		}
	}
}
