Add a hook for reporting exceptions
Bug: T100141 Change-Id: I893f8b93e09f9ef70beef46922d304fdb3600b78
This commit is contained in:
parent
1823dca496
commit
d0d539e6ba
3 changed files with 12 additions and 1 deletions
|
|
@ -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 ====
|
||||
|
||||
|
|
|
|||
|
|
@ -1842,6 +1842,11 @@ $param: Associative Array with the following additional options:
|
|||
"<div ...>$1</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
|
||||
|
|
|
|||
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue