diff options
author | Arnold Daniels <arnold@jasny.net> | 2017-01-03 22:34:46 +0100 |
---|---|---|
committer | Arnold Daniels <arnold@jasny.net> | 2017-01-03 22:34:46 +0100 |
commit | 8a32677753483c694e1fb568975cd0ca01878449 (patch) | |
tree | 0740698461e25598d4b861c809a6d746fdf80b48 /src | |
parent | ac34b91af334058bede75652f1872e75a0fff623 (diff) | |
download | error-handler-8a32677753483c694e1fb568975cd0ca01878449.zip error-handler-8a32677753483c694e1fb568975cd0ca01878449.tar.gz error-handler-8a32677753483c694e1fb568975cd0ca01878449.tar.bz2 |
Don't use logErrorTypes property in traits, but use getLoggedErrorTypes()v0.1.1
Diffstat (limited to 'src')
-rw-r--r-- | src/ErrorHandler/HandleShutdownError.php | 9 | ||||
-rw-r--r-- | src/ErrorHandler/HandleUncaughtError.php | 2 | ||||
-rw-r--r-- | src/ErrorHandler/HandleUncaughtException.php | 9 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/ErrorHandler/HandleShutdownError.php b/src/ErrorHandler/HandleShutdownError.php index 1e9907b..3397717 100644 --- a/src/ErrorHandler/HandleShutdownError.php +++ b/src/ErrorHandler/HandleShutdownError.php @@ -47,6 +47,13 @@ trait HandleShutdownError */ abstract public function log($error); + /** + * Get the types of errors that will be logged + * + * @return int Binary set of E_* constants + */ + abstract public function getLoggedErrorTypes(); + /** * Reserve memory for shutdown function in case of out of memory @@ -86,7 +93,7 @@ trait HandleShutdownError $error = new \ErrorException($err['message'], 0, $err['type'], $err['file'], $err['line']); - if ($err['type'] & $this->logErrorTypes) { + if ($err['type'] & $this->getLoggedErrorTypes()) { $this->log($error); } diff --git a/src/ErrorHandler/HandleUncaughtError.php b/src/ErrorHandler/HandleUncaughtError.php index 91b28f3..fa2be0a 100644 --- a/src/ErrorHandler/HandleUncaughtError.php +++ b/src/ErrorHandler/HandleUncaughtError.php @@ -141,7 +141,7 @@ trait HandleUncaughtError throw $error; } - if ($this->logErrorTypes & $type) { + if ($this->getLoggedErrorTypes() & $type) { $this->log($error); } } diff --git a/src/ErrorHandler/HandleUncaughtException.php b/src/ErrorHandler/HandleUncaughtException.php index 7a01bb1..4386c84 100644 --- a/src/ErrorHandler/HandleUncaughtException.php +++ b/src/ErrorHandler/HandleUncaughtException.php @@ -44,6 +44,13 @@ trait HandleUncaughtException */ abstract public function log($error); + /** + * Get the types of errors that will be logged + * + * @return int Binary set of E_* constants + */ + abstract public function getLoggedErrorTypes(); + /** * Get the error handler that has been replaced. @@ -107,7 +114,7 @@ trait HandleUncaughtException if ($exception instanceof \Error || $exception instanceof \ErrorException) { $type = $exception instanceof \Error ? $exception->getCode() : $exception->getSeverity(); - $shouldLog = $this->logErrorTypes & $type; + $shouldLog = $this->getLoggedErrorTypes() & $type; } else { $shouldLog = array_sum($isInstanceOf) > 0; } |