Skip to content

Commit f0cbf93

Browse files
committed
feat: disable logging if logger isn't installed
1 parent e48543b commit f0cbf93

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Leaf Exception (Whoops)
2+
23
PHP errors for cool kids
34

45
[![Total Downloads](https://img.shields.io/packagist/dm/leafs/exception.svg)](https://packagist.org/packages/leafs/exception)

src/Exception/General.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function handleErrors($errno, $errstr = '', $errfile = '', $errlin
6868
} catch (\Throwable $th) {
6969
$app = \Leaf\Config::get('app');
7070

71-
if ($app && $app->config('log.enabled')) {
71+
if ($app && $app->config('log.enabled') && class_exists('Leaf\Log')) {
7272
$app->logger()->error($th);
7373
}
7474

@@ -245,7 +245,7 @@ public static function defaultError($e = null)
245245
if ($e) {
246246
$app = \Leaf\Config::get('app');
247247

248-
if ($app && $app->config('log.enabled')) {
248+
if ($app && $app->config('log.enabled') && class_exists('Leaf\Log')) {
249249
$app->logger()->error($e);
250250
}
251251
}

src/Exception/Handler/PlainTextHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function handle()
336336
{
337337
$response = $this->generateResponse();
338338

339-
if ($this->getLogger()) {
339+
if ($this->getLogger() && class_exists('Leaf\Log')) {
340340
$this->getLogger()->error($response);
341341
}
342342

src/Exception/Run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public function handleError($level, $message, $file = null, $line = null)
459459
$exception = new ErrorException($message, /*code*/ $level, /*severity*/ $level, $file, $line);
460460
$app = \Leaf\Config::get('app');
461461

462-
if ($app && $app->config('log.enabled')) {
462+
if ($app && $app->config('log.enabled') && class_exists('Leaf\Log')) {
463463
$app->logger()->error($exception);
464464
}
465465

0 commit comments

Comments
 (0)