-
Notifications
You must be signed in to change notification settings - Fork 51
Add a formatter to compactly print stack traces #78
Conversation
Produces a similar format to the native PHP exception handler
You changed the php constrained in the |
$event['timestamp'] = $event['timestamp']->format($this->getDateTimeFormat()); | ||
} | ||
|
||
$output = '[' . $event['timestamp'] . '] ' . $event['priorityName'] . ' (' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are very hard to read. Please use sprintf
.
if (! empty($event['extra']['trace'])) { | ||
$output .= "Stack trace:\n"; | ||
foreach ($event['extra']['trace'] as $i => $traceLine) { | ||
$output .= "#$i " . $this->formatTraceLine($traceLine) . "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. (Don't use "#$i "
.)
} | ||
|
||
/** | ||
* {@inheritDoc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
/** | ||
* {@inheritDoc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -0,0 +1,164 @@ | |||
<?php | |||
/** | |||
* Zend Framework (http://framework.zend.com/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace the header with this:
/**
* @see https://github.com/zendframework/zend-log for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-log/blob/master/LICENSE.md New BSD License
*/
@@ -0,0 +1,63 @@ | |||
<?php | |||
/** | |||
* Zend Framework (http://framework.zend.com/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace the header with this:
/**
* @see https://github.com/zendframework/zend-log for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-log/blob/master/LICENSE.md New BSD License
*/
Bit of a misunderstanding, turns out our company will not be using this library in the near future. I'm closing the PR. |
The available formatters are very verbose. This one produces a similar format to the native PHP exception handler.
It could use some more tests.
The type of the exception is not printed, it is not available in the event.
Solves #32 if you use this formatter
PHP version is bumped to 7.0 to use the coalesce operator and more type hints