New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
require PIWIK_PRINT_ERROR_BACKTRACE for exception backtraces in logs #16640
Conversation
@@ -76,6 +76,10 @@ private function getMessage($exception) | |||
|
|||
private function getStackTrace($exception) | |||
{ | |||
if (!\Piwik_ShouldPrintBackTraceWithMessage()) { |
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.
@diosmosis can we also check all other places where we use getTraceAsString()
?
…ble which always checks if should print stacktrace
'message' => $e->getMessage(), | ||
'backtrace' => $e->getTraceAsString(), | ||
$logger->debug('Unable to unserialize a string: {exception} (string = {string})', [ | ||
'exception' => $e, |
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.
Doesn't using the exception object here cause a cast to string when it's used in the message? And __toString will show the message and the (full) backtrace. Or does the Monologger do some magic here to use the ExceptionToTextProcessor?
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.
to my understanding, ExceptionToTextProcessor should convert the 'exception' value to a string
if (!$shouldPrintBacktrace) { | ||
return $exception->getMessage(); | ||
$message = $exception->getMessage() . "\n" . self::BACKTRACE_OMITTED_MESSAGE; |
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.
fyi the message again might not be needed? In my case it causes the exception message to be shown twice
At least it happened when I triggered an exception in Common::safe_unserialize()
and thne it went into the ExceptionToTextProcessor::__invoke
. I reckon the trace does not need to append the message again
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.
I see it might be needed because of eg https://github.com/matomo-org/matomo/pull/16640/files#diff-7aeb867200acd3d0c23432f4b94edae59f9549e2b20160b83bd165830e5e2042L208
The method name might be bit misleading as it gets the message and the trace?
2a73fa1
to
ea031cc
Compare
No description provided.