<?
	/*
	 * Debuggable object, the base for all of our other objects.
	 *
	 * -side $o->setDebugging(true/false);
	 * 
	 * subclasser-side: $o->debug($msg) and $o->error($msg);
	 *
	 */

	class DebuggableObject {
		function DebuggableObject() {
			$this->debugging = false;
		}
		
		function setDebug($state) {
			$this->setDebugging($state);
		}
		
		function setDebugging($state) {
			$this->debugging = $state;
		}
		
		function inspect($val) {
			echo "<pre>";
			print_r($val);
			echo "</pre>";
		}
		
		function debug($msg) {
			if ($this->debugging) {
			
				echo htmlspecialchars($msg)."<br/>\n";
				flush();
				for ($i = 0; $i < 2048; $i++) echo "\n";
				flush();
				
				// $class = get_class($this);
				// $f = @fopen("/tmp/debug-log.txt", "a");
				// @fwrite($f, "DEBUG ($class): $msg<br/>\n");
				// @fclose($f);
			}
		}
		
		function error($msg, $func = false, $line = false, $file = false, $extra_body = false) {
			error_die($msg, $func, $line, $file, $extra_body);
		}
	}
?>
