<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Log FirePHP composite examples</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Log FirePHP</h1>
<?php
require_once 'Log.php';
$file = &Log::singleton('file', 'out.log', 'TEST');
$firephp = &Log::singleton('firephp', '', 'TEST');
$firephp->registerErrorHandler();
$composite = &Log::singleton('composite');
$composite->addChild($file);
$composite->addChild($firephp);
$composite->log('This event will be logged to both handlers.');
$composite->log(array('message' => "Log message", 'label' => "Log message label"));
$composite->log(array('message' => "Info message",
'label' => "Info message label",
'type'=> PEAR_LOG_FIREPHP_INFO),
PEAR_LOG_INFO);
$composite->log(array('message' => "Warning message",
'label' => "Warning message label",
'type'=> PEAR_LOG_FIREPHP_WARN),
PEAR_LOG_WARNING);
$composite->log(array('message' => "Error message",
'label' => "Error message label",
'type'=> PEAR_LOG_FIREPHP_ERROR),
PEAR_LOG_ERR);
$composite->log(array('message' => apache_request_headers(),
'label' => "RequestHeaders",
'type'=> PEAR_LOG_FIREPHP_DUMP),
PEAR_LOG_DEBUG);
$firephp->log(array('label' => "Backtrace to here",
'type'=> PEAR_LOG_FIREPHP_TRACE),
PEAR_LOG_DEBUG);
$table = array();
$table[] = array('SQL Statement', 'Time', 'Result');
$table[] = array('SELECT * FROM Foo', '0.02', array('row1','row2'));
$table[] = array('SELECT * FROM Bar', '0.04', array('row1','row2'));
$composite->log(array('message' => $table,
'label' => '2 SQL queries took 0.06 seconds',
'type' => PEAR_LOG_FIREPHP_TABLE),
PEAR_LOG_DEBUG);
$firephp->log(array('label' => 'Convenience functions call Group',
'type' => PEAR_LOG_FIREPHP_GROUP_START));
$composite->info(array('message' => "Info convenience message",
'label' => "Info convenience message label"));
$firephp->log(array('type' => PEAR_LOG_FIREPHP_GROUP_END));
$var = array('i' => 10, 'j' => 20);
$composite->log(array('message' => $var, 'label' => 'Iterators'));
trigger_error('This is an error log message.', E_USER_ERROR);
function test($arg)
{
throw new Exception('Test Exception');
}
try {
test(array('Hello'=>'World'));
} catch(Exception $e) {
/* Log exception including stack trace & variables */
$composite->log($e, PEAR_LOG_ALERT);
}
?>
</body>
</html>