exception: Remove "exception_id" key in favour of reqId
This key predates MediaWiki's standardised notion of request IDs, and of PSR-3 and Monolog usage. Bug: T199607 Change-Id: Ibdd5bf12591761ab45be12ba72943e9d94f678cb
This commit is contained in:
parent
8c906e237f
commit
3a044d0f02
1 changed files with 10 additions and 9 deletions
|
|
@ -317,7 +317,7 @@ class MWExceptionHandler {
|
|||
|
||||
$url = WebRequest::getGlobalRequestURL();
|
||||
$msgParts = [
|
||||
'[{exception_id}] {exception_url} PHP Fatal Error',
|
||||
'[{reqId}] {exception_url} PHP Fatal Error',
|
||||
( $line || $file ) ? ' from' : '',
|
||||
$line ? " line $line" : '',
|
||||
( $line && $file ) ? ' of' : '',
|
||||
|
|
@ -341,12 +341,7 @@ TXT;
|
|||
|
||||
$e = new ErrorException( "PHP Fatal Error: {$message}", 0, $level, $file, $line );
|
||||
$logger = LoggerFactory::getInstance( 'exception' );
|
||||
$logger->error( $msg, [
|
||||
'exception' => $e,
|
||||
'exception_id' => WebRequest::getRequestId(),
|
||||
'exception_url' => $url,
|
||||
'caught_by' => self::CAUGHT_BY_HANDLER
|
||||
] );
|
||||
$logger->error( $msg, self::getLogContext( $e, self::CAUGHT_BY_HANDLER ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -500,7 +495,7 @@ TXT;
|
|||
$type = get_class( $e );
|
||||
$message = $e->getMessage();
|
||||
|
||||
return "[{exception_id}] {exception_url} $type: $message";
|
||||
return "[{reqId}] {exception_url} $type: $message";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -530,8 +525,14 @@ TXT;
|
|||
public static function getLogContext( Throwable $e, $catcher = self::CAUGHT_BY_OTHER ) {
|
||||
return [
|
||||
'exception' => $e,
|
||||
'exception_id' => WebRequest::getRequestId(),
|
||||
'exception_url' => self::getURL() ?: '[no req]',
|
||||
// The reqId context key use the same familiar name and value as the top-level field
|
||||
// provided by LogstashFormatter. However, formatters are configurable at run-time,
|
||||
// and their top-level fields are logically separate from context keys and cannot be,
|
||||
// substituted in a message, hence set explicitly here. For WMF users, these may feel,
|
||||
// like the same thing due to Monolog V0 handling, which transmits "fields" and "context",
|
||||
// in the same JSON object (after message formatting).
|
||||
'reqId' => WebRequest::getRequestId(),
|
||||
'caught_by' => $catcher
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue