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 "<html><head><title>ZF Demo Debug Log</title></head>/n<body>/n<pre>"; echo htmlentities(self::$log, ENT_QUOTES, 'UTF-8'); echo '</pre></body></html>'; }
public static function get() { return self::$log; } }