Test '".basename(__FILE__)."' ...
\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 ... FAILED
\n";
echo "Testing ... Please remove the following logfile for this test. logfile='$logfile.0.log'.
\n";
echo "Testing ... Please remove the following logfile for this test. logfile='$logfile.1.log'.
\n";
echo "Test '".basename(__FILE__)."' ... Finished - FAILED
\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 ... PASSED
\n";
// check log file size to be at accptable size
if(filesize($logfile_name) > 100 )
{
echo "Testing ... Check log file size ... PASSED
\n";
}
else
{
echo "Testing ... Check log file size ... FAILED
\n";
echo "Testing ... The logfile seems to be too small. size='".filesize($logfile_name)."' logfile='$logfile_name'.
\n";
echo "Test '".basename(__FILE__)."' ... Finished - FAILED
\n";
return;
}
}
else
{
echo "Testing ... Check log file creation ... FAILED
\n";
echo "Testing ... The logfile was not created. logfile='$logfile_name'.
\n";
echo "Test '".basename(__FILE__)."' ... Finished - FAILED
\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' ... PASSED
\n";
}
else
{
echo "Testing ... Max file size set to '93KB' ... FAILED
\n";
}
$GLOBALS["DBG"]->set_max_filesize("7MB");
if($GLOBALS["DBG"]->max_filesize == 7000000)
{
echo "Testing ... Max file size set to '7MB' ... PASSED
\n";
}
else
{
echo "Testing ... Max file size set to '7MB' ... FAILED
\n";
}
$GLOBALS["DBG"]->set_max_filesize("1500");
if($GLOBALS["DBG"]->max_filesize == 1500)
{
echo "Testing ... Max file size set to '1500' ... PASSED
\n";
}
else
{
echo "Testing ... Max file size set to '1500' ... FAILED
\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' ... PASSED
\n";
}
else
{
echo "Testing ... Difference calculation setting 'script' ... FAILED
\n";
}
$GLOBALS["DBG"]->set_time_diff("line");
if($GLOBALS["DBG"]->timestamp_line_diff == true)
{
echo "Testing ... Difference calculation setting 'line' ... PASSED
\n";
}
else
{
echo "Testing ... Difference calculation setting 'line' ... FAILED
\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 ... PASSED
\n";
}
else
{
echo "Testing ... Log filename with sessionid enabled ... FAILED
\n";
}
$GLOBALS["DBG"]->set_sessid_filename(false);
if($GLOBALS["DBG"]->sessid_in_filename == false)
{
echo "Testing ... Log filename with sessionid disabled ... PASSED
\n";
}
else
{
echo "Testing ... Log filename with sessionid disabled ... FAILED
\n";
}
//
// Check filename with sessionid - END
//
//
// Check disabling types
//
echo "Testing ... Disable log types ... Planned
\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 ... Logfile = ".basename($logfile_name)."
\n";
$GLOBALS["DBG"]->performance("Testing test performance", "start");
echo "Testing ... Start PERFORMANCE mesurement ... Start
\n";
$GLOBALS["DBG"]->debug("Test message of the type DEBUG");
echo "Testing ... Send DEBUG log message ... Logfile = ".basename($logfile_name)."
\n";
$GLOBALS["DBG"]->debug2("Test message of the type DEBUG2");
echo "Testing ... Send DEBUG2 log message ... Logfile = ".basename($logfile_name)."
\n";
$GLOBALS["DBG"]->debug_array("Test message of the type DEBUG_ARRAY", $GLOBALS);
echo "Testing ... Send DEBUG_ARRAY log message ... Logfile = ".basename($logfile_name)."
\n";
$GLOBALS["DBG"]->debug2_array("Test message of the type DEBUG2_ARRAY", $GLOBALS);
echo "Testing ... Send DEBUG2_ARRAY log message ... Logfile = ".basename($logfile_name)."
\n";
$GLOBALS["DBG"]->error("Test message of the type ERROR");
echo "Testing ... Send ERROR log message ... Logfile = ".basename($logfile_name)."
\n";
$GLOBALS["DBG"]->performance("Test message of type PERFORMANCE", "stop");
echo "Testing ... Stop PERFORMANCE log message ... Logfile = ".basename($logfile_name)."
\n";
//
// Send a log message of all types - END
//
echo "Testing ... *** Please check the log file(s) to verify correct logging. ***
\n";
echo "Test '".basename(__FILE__)."' ... Finished.
\n";
?>