/* usage:
write in:
ZFDemo_Log::log("PHP extensions loaded = /n " . implode("/n ", $extensions));
or:
ZFDemo_Log::log("The '$ext' extension is required, but not currently loaded by php.");
ZFDemo_Log::log("Zend_Session.ini=" . print_r($sessionConfig->toArray(), true));
output:
ZFDemo_Log::show();
require_once('zfdemo_log.php');
*/
class ZFDemo_Log
{
// very simple running log of "debug/" messages to highlight inner workings of demo
public static $log = '';
/**
* Accumulate log messages, but also append them to a running log file for easy viewing.
*/
public static function log($msg, $before = null)
{
static $flushed = false;
if ($before) {
self::$log = "$msg/n" . self::$log;
} else {
self::$log .= "$msg/n";
}
$logfile = 'log.txt';
// performance is not an issue, so just sync to disk everytime
if (isset($logfile)) {
if ($flushed) {
file_put_contents($logfile, "$msg/n", FILE_APPEND);
} else {
file_put_contents($logfile, self::$log);
}
$flushed = true;
}
}
/*
* Useful if you modify the demo, and need to quickly see the debug log in your browser.
*/
public static function show()
{
echo "
ZF Demo Debug Log/n/n";
echo htmlentities(self::$log, ENT_QUOTES, 'UTF-8');
echo '
';}
public static function get()
{
return self::$log;
}
}