Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
use same hashes for file names as Tracy
Browse files Browse the repository at this point in the history
  • Loading branch information
VasekPurchart committed Mar 14, 2018
1 parent 7e681f9 commit a1c0df9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"require": {
"php": "~7.0",
"monolog/monolog": "~1.1",
"tracy/tracy": "~2.3.0|~2.4.0"
"tracy/tracy": "~2.4.0"
},
"require-dev": {
"jakub-onderka/php-console-highlighter": "0.3.2",
Expand Down
12 changes: 11 additions & 1 deletion src/Tracy/LoggerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ public function renderToFile($exception, DateTimeInterface $datetime = NULL)
*/
public function getExceptionHash($exception)
{
return substr(md5(preg_replace('~(Resource id #)\d+~', '$1', $exception)), 0, 10);
$tracyExceptionFilePath = parent::getExceptionFile($exception);
$matches = [];
preg_match('~^.*--(?P<hash>[a-fA-F0-9]+).html$~', $tracyExceptionFilePath, $matches);
if (!isset($matches['hash'])) {
// @codeCoverageIgnoreStart
// not testable since it would be eventually coming from parent
throw new \Nella\MonologTracy\Tracy\NotSupportedException('Non-compatible exception file name -> unexpected Tracy version.');
}
// @codeCoverageIgnoreEnd

return $matches['hash'];
}

/**
Expand Down

0 comments on commit a1c0df9

Please sign in to comment.