hfile = $file; $this->i_opened_it = FALSE; else: $this->hfile = fopen($file, 'ab'); $this->i_opened_it = TRUE; fwrite($this->hfile, "**** BEGINNING DEBUG SESSION AT " . strftime("%D %T") . " ****\n"); endif; else: $this->hfile = NULL; endif; } function __destructor () { if (!is_null($this->hfile) && $this->i_opened_it): fwrite($this->hfile, "**** CLOSING DEBUG SESSION AT " . strftime("%D %T") . " ****\n\n"); fclose($this->hfile); endif; } /* Debugger::__destructor () */ function log ($text, $file = NULL, $func = NULL, $line = NULL) { if (!is_null($this->hfile)) { $out = NULL; if (!is_null($file)) $out .= basename($file) . ":"; if (!is_null($func)) $out .= $func . "():"; if (!is_null($line)) $out .= "[" . $line . "]"; if (!is_null($out)) $out .= " "; fwrite($this->hfile, $out . str_repeat("| ", $this->indent) . $text . "\n"); } /* if */ } /* Debugger::log () */ function increment_indent () { $this->indent = $this->indent + 1; } /* Debugger::increment_indent () */ function decrement_indent () { if ($this->indent > 0) $this->indent = $this->indent - 1; } /* Debugger::increment_indent () */ function clear_indent () { $this->indent = 0; } /* Debugger::increment_indent () */ function set ($key, $value) { $this->bb[$key] = $value; } /* Debugger::set () */ function get ($key) { return $this->bb[$key]; } /* Debugger::get () */ function &plug_in ($filename, &$global) { unset($ret); if (!is_null($GLOBALS["DEBUGGER"]) and is_a($GLOBALS["DEBUGGER"], "Debugger")): $ret =& $GLOBALS["DEBUGGER"]; $global = TRUE; else: $ret =& new Debugger(BASE_FILE_PATH."debug/" . basename($filename) . ".log", __DEBUG__); $global = FALSE; endif; return $ret; } /* Debugger::plug_in () */ function unplug (&$deb, $global) { if (!$global): Destroy($deb); endif; } /* Debugger::unplug () */ } /* Debugger */ define(__DEBUG__, TRUE); ?>