Skip to content

Commit

Permalink
take the sting out of using strings
Browse files Browse the repository at this point in the history
  • Loading branch information
alexberryman committed Apr 1, 2019
1 parent dde0167 commit 38b19bb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Process/Pool/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class Logger extends Log\AbstractLogger implements LoggerInterface
use Time\AwareTrait;
use Logger\Message\Factory\AwareTrait;
use Defensive\AwareTrait;

public const PROP_IS_ENABLED = 'is_enabled';
public const CONTEXT_KEY_EXCEPTION = 'exception';
public const CONTEXT_KEY_EXCEPTION_STRING = 'exception_string';

protected const LOG_DATE_TIME_FORMAT = 'D, d M y H:i:s.u T';
const CONTEXT_KEY_EXCEPTION = 'exception';

protected $log_formatter;
protected $level_filter_mask;
Expand Down Expand Up @@ -54,10 +57,10 @@ public function log($level, $message, array $context = [])

if (array_key_exists(self::CONTEXT_KEY_EXCEPTION, $context) && $context[self::CONTEXT_KEY_EXCEPTION]
instanceof \Throwable){
$context['exception_sting'] = (string)$context[self::CONTEXT_KEY_EXCEPTION];
$context[self::CONTEXT_KEY_EXCEPTION_STRING] = (string)$context[self::CONTEXT_KEY_EXCEPTION];
$normalizedException = (new NormalizerFormatter())->format([$context[self::CONTEXT_KEY_EXCEPTION]]);
unset($context[self::CONTEXT_KEY_EXCEPTION]);
$context['exception'] = $normalizedException[0];
$context[self::CONTEXT_KEY_EXCEPTION] = $normalizedException[0];
}

if (json_encode($context) === false) {
Expand Down

0 comments on commit 38b19bb

Please sign in to comment.