<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/sr/constant.config.php');
include_once($_SERVER['DOCUMENT_ROOT'].'/sr/classes/exceptions/mysql.ex.php');
/** class logwriter
* @name logwriter
* @author mario xenji mueller
*/
class logwriter {
/**
* @name logfile
* @var filename
*/
private $logfile;
/**
* @name exception object
* @var thrown exception object
*/
private $exobj;
/**
* @name constructor
* @param Object $obj Exception object
* @param String $logfile
*/
public function __construct($obj, $logfile = false) {
if(is_object($obj))
$this->exobj = $obj;
else
trigger_error('no exception object found!',E_USER_WARNING);
if($logfile == false || $logfile == " " || empty($logfile))
$this->logfile = ERR_LOGFILE;
$this->addlog();
}
/**
* @name add log
* @param none
*/
public function addlog() {
$filehandle = fopen(P_LOGS.$this->logfile,'a');
$ec = array();
$ec['msg']= $this->exobj->getMessage();
$ec['code']= $this->exobj->getCode();
$ec['line']= $this->exobj->getLine();
$ec['file']= $this->exobj->getFile();
$ec['dt']= date('d.m.Y @ H:i:s ');
$logmsg = <<<EOD
###BEGIN###
Date: $ec[dt]
Message: $ec[msg]
Line: $ec[line]
Code: $ec[code]
------------------
File: $ec[file]
Desc: $ec[desc]
###E N D###
EOD;
if(fwrite($filehandle, $logmsg))
fclose($filehandle);
else
trigger_error('Cannot write logfile!', E_USER_WARNING);
}
}
/**
* class display error
* @author mario xenji mueller
* @name display error
*/
class displayerror {
/**
* @name Display Layer instance
* @param object
*/
private $display;
/**
* @name template file
* @param string path
*/
private $template;
/**
* @name exception object
* @param object
*/
private $exobj;
/**
* @name constructor
* @param Object $exobj
* @param Object $dispobj
* @param String template file
*/
public function __construct($exobj, $dispobj = false) {
if(is_object($exobj))
$this->exobj = $exobj;
else
trigger_error('no exception object found! got lost on the way ?',E_USER_WARNING);
if(is_object($dispobj))
$this->display = $dispobj;
else
trigger_error('no display object found for error presentation!',E_USER_WARNING);
$this->toScreen();
}
/**
* @name send toScreen
* @returns nothing, but prints html
* ATTENTION: Change this method to any display layer you make use of!
* This case is for andreas demmers P.E.T. engine.
*/
private function toScreen() {
$this->display->msg = $this->exobj->getMessage();
$this->display->code = $this->exobj->getCode();
$this->display->line = $this->exobj->getLine();
$this->display->file = $this->exobj->getFile();
print($this->display->fetch());
}
} #eoc
?>