Modify query_error() to log errors to a database table instead of displaying them on the screen. This should
let us more easily debug difficult or intermittent issues that users may not report. Add a cron to report logged errors to appdb admins every night. Implement some basic unit tests for the new error logging code
This commit is contained in:
40
unit_test/test_error_log.php
Normal file
40
unit_test/test_error_log.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
require_once("path.php");
|
||||
require_once(BASE."include/incl.php");
|
||||
|
||||
function test_error_log_log_error()
|
||||
{
|
||||
error_log::log_error(ERROR_SQL, "This is a sql error");
|
||||
error_log::log_error(ERROR_GENERAL, "This is a general error");
|
||||
|
||||
/* make sure the error log count matches what we expect */
|
||||
$iExpected = 2;
|
||||
$iActual = error_log::getEntryCount();
|
||||
if($iActual != $iExpected)
|
||||
{
|
||||
echo "Expected error_log::getEntryCount() of ".$iExpected." got ".$iActual;
|
||||
return false;
|
||||
}
|
||||
|
||||
error_log::flush(); /* flush the error log */
|
||||
|
||||
/* make sure the error log count matches what we expect */
|
||||
$iExpected = 0;
|
||||
$iActual = error_log::getEntryCount();
|
||||
if($iActual != $iExpected)
|
||||
{
|
||||
echo "Expected error_log::getEntryCount() of ".$iExpected." got ".$iActual;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(!test_error_log_log_error())
|
||||
echo "test_error_log_log_error() failed!\n";
|
||||
else
|
||||
echo "test_error_log_log_error() passed\n";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user