<?php
/*******************************************************************************
*
* @author Gerhard STEINBEIS ( gerhard . steinbeis [at] handykick [.] at )
* @version 0.1
*
* @package framework
*
* General Framework initialisation
*
*******************************************************************************/
include_once(dirname(__FILE__).'/../classes/debug_logging.class.php');
echo "<b>Test '".basename(__FILE__)."' ... </b><br/>\n";
// if set delete old logging object
$GLOBALS["DBG"] = null;
unset($GLOBALS["DBG"]);
// Create object of logging
$logfile = dirname(__FILE__)."/../log/".basename(__FILE__);
// delete file if exists
if(file_exists($logfile.".0.log")) unlink($logfile.".0.log");
// check if the file exists
if(file_exists($logfile.".0.log") || file_exists($logfile.".1.log"))
{
echo "Testing ... Check log file creation ... <b><font color=red>FAILED</font></b><br/>\n";
echo "Testing ... Please remove the following logfile for this test. logfile='$logfile.0.log'.<br/>\n";
echo "Testing ... Please remove the following logfile for this test. logfile='$logfile.1.log'.<br/>\n";
echo "<b>Test '".basename(__FILE__)."' ... Finished - <font color=red>FAILED</font></b><br/><br/>\n";
return;
}
else
{
// create log object
$GLOBALS["DBG"] = new Debug_Logging(true, $logfile, false);
$logfile_name = $GLOBALS["DBG"]->filename;
// send first log message
$GLOBALS["DBG"]->info("Test message of the type INFO");
// check if file was created
if(file_exists($logfile_name))
{
echo "Testing ... Check log file creation ... <b><font color=green>PASSED</font></b><br/>\n";
// check log file size to be at accptable size
if(filesize($logfile_name) > 100 )
{
echo "Testing ... Check log file size ... <b><font color=green>PASSED</font></b><br/>\n";
}
else
{
echo "Testing ... Check log file size ... <b><font color=red>FAILED</font></b><br/>\n";
echo "Testing ... The logfile seems to be too small. size='".filesize($logfile_name)."' logfile='$logfile_name'.<br/>\n";
echo "<b>Test '".basename(__FILE__)."' ... Finished - <font color=red>FAILED</font></b><br/><br/>\n";
return;
}
}
else
{
echo "Testing ... Check log file creation ... <b><font color=red>FAILED</font></b><br/>\n";
echo "Testing ... The logfile was not created. logfile='$logfile_name'.<br/>\n";
echo "<b>Test '".basename(__FILE__)."' ... Finished - <font color=red>FAILED</font></b><br/><br/>\n";
return;
}
}
//
// Check file size settings
//
$GLOBALS["DBG"]->set_max_filesize("93KB");
if($GLOBALS["DBG"]->max_filesize == 93000)
{
echo "Testing ... Max file size set to '93KB' ... <b><font color=green>PASSED</font></b><br/>\n";
}
else
{
echo "Testing ... Max file size set to '93KB' ... <b><font color=red>FAILED</font></b><br/>\n";
}
$GLOBALS["DBG"]->set_max_filesize("7MB");
if($GLOBALS["DBG"]->max_filesize == 7000000)
{
echo "Testing ... Max file size set to '7MB' ... <b><font color=green>PASSED</font></b><br/>\n";
}
else
{
echo "Testing ... Max file size set to '7MB' ... <b><font color=red>FAILED</font></b><br/>\n";
}
$GLOBALS["DBG"]->set_max_filesize("1500");
if($GLOBALS["DBG"]->max_filesize == 1500)
{
echo "Testing ... Max file size set to '1500' ... <b><font color=green>PASSED</font></b><br/>\n";
}
else
{
echo "Testing ... Max file size set to '1500' ... <b><font color=red>FAILED</font></b><br/>\n";
}
//
// Check file size settings - END
//
//
// Check the diff time calculation
//
$GLOBALS["DBG"]->set_time_diff("script");
if($GLOBALS["DBG"]->timestamp_line_diff == false)
{
echo "Testing ... Difference calculation setting 'script' ... <b><font color=green>PASSED</font></b><br/>\n";
}
else
{
echo "Testing ... Difference calculation setting 'script' ... <b><font color=red>FAILED</font></b><br/>\n";
}
$GLOBALS["DBG"]->set_time_diff("line");
if($GLOBALS["DBG"]->timestamp_line_diff == true)
{
echo "Testing ... Difference calculation setting 'line' ... <b><font color=green>PASSED</font></b><br/>\n";
}
else
{
echo "Testing ... Difference calculation setting 'line' ... <b><font color=red>FAILED</font></b><br/>\n";
}
//
// Check the diff time calculation - END
//
//
// Check filename with sessionid
//
$GLOBALS["DBG"]->set_sessid_filename(true);
if($GLOBALS["DBG"]->sessid_in_filename == true)
{
echo "Testing ... Log filename with sessionid enabled ... <b><font color=green>PASSED</font></b><br/>\n";
}
else
{
echo "Testing ... Log filename with sessionid enabled ... <b><font color=red>FAILED</font></b><br/>\n";
}
$GLOBALS["DBG"]->set_sessid_filename(false);
if($GLOBALS["DBG"]->sessid_in_filename == false)
{
echo "Testing ... Log filename with sessionid disabled ... <b><font color=green>PASSED</font></b><br/>\n";
}
else
{
echo "Testing ... Log filename with sessionid disabled ... <b><font color=red>FAILED</font></b><br/>\n";
}
//
// Check filename with sessionid - END
//
//
// Check disabling types
//
echo "Testing ... Disable log types ... <b><font color=blue>Planned</font></b><br/>\n";
//
// Check disabling types - END
//
//
// Send a log message of all types
//
$logfile_name = $GLOBALS["DBG"]->filename;
$GLOBALS["DBG"]->info("Test message of the type INFO");
echo "Testing ... Send INFO log message ... <b><font color=grey>Logfile = ".basename($logfile_name)."</font></b><br/>\n";
$GLOBALS["DBG"]->performance("Testing test performance", "start");
echo "Testing ... Start PERFORMANCE mesurement ... <font color=grey>Start</font><br/>\n";
$GLOBALS["DBG"]->debug("Test message of the type DEBUG");
echo "Testing ... Send DEBUG log message ... <b><font color=grey>Logfile = ".basename($logfile_name)."</font></b><br/>\n";
$GLOBALS["DBG"]->debug2("Test message of the type DEBUG2");
echo "Testing ... Send DEBUG2 log message ... <b><font color=grey>Logfile = ".basename($logfile_name)."</font></b><br/>\n";
$GLOBALS["DBG"]->debug_array("Test message of the type DEBUG_ARRAY", $GLOBALS);
echo "Testing ... Send DEBUG_ARRAY log message ... <b><font color=grey>Logfile = ".basename($logfile_name)."</font></b><br/>\n";
$GLOBALS["DBG"]->debug2_array("Test message of the type DEBUG2_ARRAY", $GLOBALS);
echo "Testing ... Send DEBUG2_ARRAY log message ... <b><font color=grey>Logfile = ".basename($logfile_name)."</font></b><br/>\n";
$GLOBALS["DBG"]->error("Test message of the type ERROR");
echo "Testing ... Send ERROR log message ... <b><font color=grey>Logfile = ".basename($logfile_name)."</font></b><br/>\n";
$GLOBALS["DBG"]->performance("Test message of type PERFORMANCE", "stop");
echo "Testing ... Stop PERFORMANCE log message ... <b><font color=grey>Logfile = ".basename($logfile_name)."</font></b><br/>\n";
//
// Send a log message of all types - END
//
echo "Testing ... *** Please check the log file(s) to verify correct logging. ***<br/>\n";
echo "<b>Test '".basename(__FILE__)."' ... Finished.</b><br/><br/>\n";
?>
|