13 require_once(dirname(__FILE__) .
'/../../shared/library/logging.i');
14 require_once(dirname(__FILE__) .
'/../../shared/library/hcuCommon.i');
16 define(
'HCU_PRODUCT_BANKING', 0);
17 define(
'HCU_PRODUCT_ADMIN', 1);
18 define(
'HCU_PRODUCT_MONITOR', 2);
30 protected $errReportLvl = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED;
38 private $saveLog =
false;
39 private $showErrPage =
false;
41 private $errPageUrl =
'';
46 private $noticeOnly =
false;
53 private $hcuProduct =
null;
62 private $hcuDevMode = 0;
74 protected $errRemoteAddr;
75 protected $errRequestUri;
76 protected $errServerName;
77 protected $errPhpSelf;
78 protected $errScriptName;
79 protected $errQueryString;
88 $this->hcuProduct = $pSetProduct;
110 $lLogMsg = $this->getErrMsg();
113 if (!is_null($this->errLogger)) {
114 if ($this->noticeOnly) {
116 $this->errLogger->notice($lLogMsg);
119 $this->errLogger->error($lLogMsg);
139 $this->errRemoteAddr = (array_key_exists(
"REMOTE_ADDR", $_SERVER) ? $_SERVER[
'REMOTE_ADDR'] :
'0.0.0.0');
140 $this->errRequestUri = (array_key_exists(
"REQUEST_URI", $_SERVER) ? $_SERVER[
'REQUEST_URI'] :
'127.0.0.1');
141 $this->errServerName = (array_key_exists(
"SERVER_NAME", $_SERVER) ? $_SERVER[
'SERVER_NAME'] :
'');
142 $this->errPhpSelf = (array_key_exists(
"PHP_SELF", $_SERVER) ? $_SERVER[
'PHP_SELF'] :
'');
143 $this->errScriptFileName = (array_key_exists(
"SCRIPT_FILENAME", $_SERVER) ? $_SERVER[
'SCRIPT_FILENAME'] : __FILE__);
144 $this->errQueryString = (array_key_exists(
"QUERY_STRING", $_SERVER) ? $_SERVER[
'QUERY_STRING'] :
'');
146 if ($this->saveLog) {
151 protected function setSaveLog($pSaveLog) {
152 $this->saveLog = $pSaveLog;
154 protected function getErrMsg() {
157 protected function setNotice($pNoticeOnly) {
158 $this->noticeOnly = $pNoticeOnly;
175 if (is_a($pLogger,
'StandardLogger')) {
176 $this->errLogger = $pLogger;
180 public function setDevMode($pDevMode) {
181 $this->hcuDevMode = $pDevMode;
189 public function getDevMode() {
190 return $this->hcuDevMode;
202 $this->errReportLvl = $pNewReportLvl;
203 return error_reporting($pNewReportLvl);
214 return $this->errReportLvl;
223 private $errException =
null;
225 private function getSaveLog() {
229 function __construct($pSetProduct, $pSetLogger=
null, $pDevMode=
false) {
230 parent::__construct($pSetProduct, $pSetLogger);
232 $this->setDevMode($pDevMode);
246 include_once(dirname(__FILE__) .
'/../../shared/includes/hcuBadRequest.i');
258 $this->errException = $pException;
260 $this->setSaveLog($this->getSaveLog());
262 parent::handleError();
278 $lCurDate = date(
"Ymd:His");
280 $lRetStr = <<< LOGMSG
281 [{$lCurDate}] {$this->errException->getCode()} [{$this->errRemoteAddr}] [{$this->errServerName}{$this->errPhpSelf}?{$this->errQueryString}] [{$this->errException->getFile()}] [Line {$this->errException->getLine()}] [{$this->errException->getCode()}] {$this->errException->getMessage()}
284 if ($this->getDevMode()) {
289 $lRetStr .= $this->errException->getTraceAsString();
321 private $errConstants = Array (
323 "2" =>
"[E_WARNING]",
326 "16" =>
"[E_CORE_ERROR]",
327 "32" =>
"[E_CORE_WARNING]",
328 "64" =>
"[E_COMPILE_ERROR]",
329 "128" =>
"[E_COMPILE_WARNING]",
330 "256" =>
"[E_USER_ERROR]",
331 "512" =>
"[E_USER_WARNING]",
332 "1024" =>
"[E_USER_NOTICE]",
333 "2048" =>
"[E_STRICT]",
334 "4096" =>
"[E_RECOVERABLE_ERROR]",
335 "8192" =>
"[E_DEPRECATED]",
336 "16384" =>
"[E_USER_DEPRECATED]",
352 "file-get-contents",
"SSL: fatal protocol" 366 parent::setNotice(
false);
370 switch ($this->errNo) {
373 parent::setNotice(
true);
384 case E_USER_DEPRECATED:
392 $retVal = (in_array(basename($this->errFile), $this->ignoreFileErrors) ===
false);
396 $retVal = (in_array($this->errStr, $this->ignoreErrorString) ===
false);
403 function __construct($pSetProduct, $pSetLogger=
null, $pDevMode=
false) {
404 parent::__construct($pSetProduct, $pSetLogger);
406 $this->setDevMode($pDevMode);
410 public function catchError($pErrNo, $pErrStr, $pErrFile, $pErrLine) {
413 $this->errNo = $pErrNo;
414 $this->errStr = $pErrStr;
415 $this->errFile = $pErrFile;
416 $this->errLine = $pErrLine;
417 $this->errType = (array_key_exists($pErrNo, $this->errConstants) ? $this->errConstants[$pErrNo] :
"UNKNOWN");
421 parent::handleError();
434 $lCurDate = date(
"Ymd:His");
435 $lCurDate = date(
"d/M/Y:H:i:s");
438 $lRetStr = <<< LOGMSG
439 [{$lCurDate}] $this->errType [{$this->errRemoteAddr}] [{$this->errServerName}{$this->errPhpSelf}?{$this->errQueryString}] [$this->errFile] [Line $this->errLine] [$this->errNo] $this->errStr
453 $this->ignoreFileErrors[] = $pFileName;
462 $this->ignoreErrorString[] = $pFileName;
logException($pException)
__construct($pSetProduct, $pSetLogger=null)
catchException($pException)
addErrStrIgnore($pFileName)
setErrorReporting($pNewReportLvl)
addFileIgnore($pFileName)