Caveman profiling with a side of “where were you at 9pm on the night in question?” As always, season to taste.
<?
$_profile_log = "/tmp/php-profile.log";
function _profile() {
static $fh;
if( !isset($fh) ) {
global $_profile_log;
if( !file_exists($_profile_log) ) {
@touch( $_profile_log );
@chmod( $_profile_log, 0664 );
}
$fh = @fopen( $_profile_log, "a" );
}
if( !$fh )
return false;
$stack = debug_backtrace();
if( $stack[1] )
$base = $stack[1];
else
$base = $stack[0];
$buf = $base['file'].":".$base['line'].", ";
if( $base['class'] )
$buf .= $base['class'].$base['type'];
$buf .= $base['function'];
$buf = sprintf("[%s] %s\n",date("H:i:s"),$buf);
return @fwrite( $fh, $buf );
}
?>