logfile = fopen($_logfile, 'w+'); } function trace() { // Dissect the call. $backtrace = debug_backtrace(); $caller1 = $backtrace[3]; $caller2 = $backtrace[2]; $dir = dirname(dirname(__FILE__)); $file = substr($caller2['file'], strlen($dir) + 1); $func = $caller1['function']; $line = $caller2['line']; // Fake some strace output. list($msec, $sec) = explode(' ', microtime()); $args = func_get_args(); $comment = func_num_args() ? call_user_func_array('sprintf', $args) : ''; $msec = (int)($msec * 1000000); $str = "MARK: $file($line): $func, $comment"; $access = sprintf("0000 $sec.%06d access(\"$str\", F_OK)\n", $msec); if ($this->logfile) fwrite($this->logfile, $access); } } ?>