Location: PHPKode > projects > Aratix > aratix/classes/Debug.class.php
<?php
/*
** Aratix
** Version 0.1.0beta8 (Anubis)
**
** Autor: Manuel Burghammer
** E-Mail: hide@address.com
** Homepage: http://www.xitara.net
**
** File: Debug.class.php - Version 0.1.0 build 51
**
** Last Modified: 29.05.2006 - 19:55:46

define("LOG", 1);
define("WARN", 2);
define("ERROR", 3);
define("DEBUG", 4);

aufruf ├╝ber

$class->write([0-4], "Logtext", __FILE__, __CLASS__, __METHOD__, __FUNCTION__, __LINE__);

*/

class Debug{
	function __construct($debug_level = ''){
		if($debug_level == ""){
// 			$this->display("no_debug_level");
			$debug_level = 0;
		}
		$this->debug_level = $debug_level;

		if(is_dir("logs"))
			$log_dir = "logs/";
		else
			$log_dir = "../logs/";

		define("LOG", 1);
		define("WARN", 2);
		define("ERROR", 3);
		define("DEBUG", 4);

		$this->debug[1] = "LOG";
		$this->debug[2] = "WARN";
		$this->debug[3] = "ERROR";
		$this->debug[4] = "DEBUG";

		if($debug_level > 0)
			$this->handle[0] = fopen($log_dir . "full.log", "a");
		if($debug_level >= 1)
			$this->handle[1] = fopen($log_dir . "access.log", "a");
		if($debug_level >= 2)
			$this->handle[2] = fopen($log_dir . "warn.log", "a");
		if($debug_level >= 3)
			$this->handle[3] = fopen($log_dir . "error.log", "a");
		if($debug_level >= 4)
			$this->handle[4] = fopen($log_dir . "debug.log", "a");

		$this->write(4, "Debugging aktiviert", __FILE__, __CLASS__, __METHOD__, __FUNCTION__, __LINE__);
	}
	function write($level, $text, $file, $class, $method, $function, $line){
		if($this->debug_level < $level)
			return;

		$remote_addr = $_SERVER['REMOTE_ADDR'];
		$request_method = $_SERVER['REQUEST_METHOD'];
		$server_name = $_SERVER['SERVER_NAME'];
		$timestamp = date("Y/m/d H:i:s");

		$log_string = $timestamp . " [" . $this->debug[$level] . "] " . $remote_addr . "/" . $request_method . " " . $server_name . " - " . basename($file) . " line " . $line;

// 		 . " :: " . $class . " :: " . $method . " :: " . $function . " :: " . $line .
		$log_string .= " -> \"" . $text . "\"";
		$log_string .= "\n";

		fwrite($this->handle[0], $log_string);
		fwrite($this->handle[$level], $log_string);
	}
	function display($display_text){
		echo $display_text;
	}
	function __destruct(){
		if($this->debug_level > 0)
			fclose($this->handle[0]);
		if($this->debug_level >= 1)
			fclose($this->handle[1]);
		if($this->debug_level >= 2)
			fclose($this->handle[2]);
		if($this->debug_level >= 3)
			fclose($this->handle[3]);
		if($this->debug_level >= 4)
			fclose($this->handle[4]);
	}
}
?>
Return current item: Aratix