php Exception
1933 ワード
Class Exceptions extends Exception
{
/**
*
* @public string
*/
//public $_Dir = '';
public $_Dir = LOG_DIR;
/**
*
* @public string
* date , 'Exception_'.date('m-d').'.log'
*/
//public $_Filename = 'Error.log';
public $_Filename = LOG_FILENAME;
public function __construct($_Message=0, $_Code=0)
{
parent::__construct($_Message, $_Code);
}
public function __toString()
{
return date('[m-d-Y H:i:s]')." [{$this->code}] {$this->message} IN {$this->file} on LINE {$this->line} - {$_SERVER['REQUEST_URI']}";
}
public function Log()
{
error_log($this->__toString()."\r
", 3, $this->_Dir.$this->_Filename);
return $this;
}
public function View()
{
$_Code= "<html>
<head>
<title> </title>
</head>
<body>
<div style='color:#ea0000;font-size:22px;font-weight:bold;'>%s </div>
".
"<hr><div style='color:#666;font-size:16px;background:#f6f6f6;padding:8px;line-height:25px'>
".
" %s , :
".
"<div style='font-size:14px;'>
<li> : %s<br>
<li> : %s<br>
<li> : %1\$s<br>
<li> : %s<br>
".
"<li> : %s<br>
</div>
</div>
</body>
</html>";
echo sprintf($_Code, $this->code, $_SERVER['REQUEST_URI'], $this->file, $this->line, $this->message, date('Y-m-d H:i:s'));
return $this;
}
}