Skip to content

Commit

Permalink
Only enable error reporting in "production mode"
Browse files Browse the repository at this point in the history
Production mode is when $config['debug'] is false.
  • Loading branch information
jbelien committed Aug 20, 2019
1 parent bc91be6 commit a7861bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Listener/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public function __invoke(Throwable $error, ServerRequestInterface $request, Resp
}
}

public function isEnabled(): bool
{
return $this->debug === false;
}

/**
* Adds a log record at an arbitrary level.
*
Expand Down
5 changes: 4 additions & 1 deletion src/ListenerDelegator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public function __invoke(ContainerInterface $container, $name, callable $callbac

/** @var \Zend\Stratigility\Middleware\ErrorHandler $errorHandler */
$errorHandler = $callback();
$errorHandler->attachListener($listener);

if ($listener->isEnabled() === true) {
$errorHandler->attachListener($listener);
}

return $errorHandler;
}
Expand Down

0 comments on commit a7861bc

Please sign in to comment.