Skip to content

Commit

Permalink
Merge pull request #5 from polderknowledge/feature/factory-implementa…
Browse files Browse the repository at this point in the history
…tion

Added a factory implementation to the HumanReadableExceptionFormatter
  • Loading branch information
waltertamboer authored Apr 12, 2018
2 parents 00ebf86 + cddbbc0 commit 088a04f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Formatter/HumanReadableExceptionFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@

use Monolog\Formatter\FormatterInterface;
use Monolog\Formatter\NormalizerFormatter;
use WShafer\PSR11MonoLog\FactoryInterface;

/**
* Format an Exception in a similar way PHP does by default when an exception bubbles to the top
*/
class HumanReadableExceptionFormatter extends NormalizerFormatter implements FormatterInterface
class HumanReadableExceptionFormatter extends NormalizerFormatter implements FormatterInterface, FactoryInterface
{
public function __invoke(array $options)
{
if (array_key_exists('dateFormat', $options)) {
return new self($options['dateFormat']);
}

return new self();
}

public function format(array $record): string
{
$exception = $record['context']['exception'] ?? null;
Expand Down

0 comments on commit 088a04f

Please sign in to comment.