Add a hook for reporting exceptions

Bug: T100141
Change-Id: I893f8b93e09f9ef70beef46922d304fdb3600b78
This commit is contained in:
Gergő Tisza 2015-05-24 11:30:10 +00:00 committed by BryanDavis
parent 1823dca496
commit d0d539e6ba
3 changed files with 12 additions and 1 deletions

View file

@ -15,6 +15,7 @@ production.
"tag-<id>" interface message.
* ':' (colon) is now invalid in usernames for new accounts. Existing accounts
are not affected.
* Added a new hook, 'LogException', to log exceptions in nonstandard ways.
==== External libraries ====

View file

@ -1842,6 +1842,11 @@ $param: Associative Array with the following additional options:
"&lt;div ...>$1&lt;/div>").
- flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
'LogException': Called before an exception (or PHP error) is logged. This is meant for integration
with external error aggregation services; returning false will NOT prevent logging.
$e: The exception (in case of a plain old PHP error, a wrapping ErrorException)
$suppressed: true if the error was suppressed via error_reporting()/wfSuppressWarnings()
'LoginAuthenticateAudit': A login attempt for a valid user account either
succeeded or failed. No return data is accepted; this hook is for auditing only.
$user: the User object being authenticated against

View file

@ -486,6 +486,8 @@ TXT;
if ( $json !== false ) {
wfDebugLog( 'exception-json', $json, 'private' );
}
Hooks::run( 'LogException', array( $e, false ) );
}
}
@ -501,7 +503,8 @@ TXT;
// The set_error_handler callback is independent from error_reporting.
// Filter out unwanted errors manually (e.g. when wfSuppressWarnings is active).
if ( ( error_reporting() & $e->getSeverity() ) !== 0 ) {
$suppressed = ( error_reporting() & $e->getSeverity() ) === 0;
if ( !$suppressed ) {
$log = self::getLogMessage( $e );
if ( $wgLogExceptionBacktrace ) {
wfDebugLog( $channel, $log . "\n" . $e->getTraceAsString() );
@ -515,5 +518,7 @@ TXT;
if ( $json !== false ) {
wfDebugLog( "$channel-json", $json, 'private' );
}
Hooks::run( 'LogException', array( $e, $suppressed ) );
}
}