Merge "Even more logging"

This commit is contained in:
jenkins-bot 2017-08-24 21:08:15 +00:00 committed by Gerrit Code Review
commit 16fb61c355

View file

@ -161,9 +161,16 @@ class LoginNotify implements LoggerAwareInterface {
*/ */
private function isKnownSystemSlow( User $user, $subnet, $resultSoFar = null ) { private function isKnownSystemSlow( User $user, $subnet, $resultSoFar = null ) {
$result = $this->checkUserAllWikis( $user, $subnet ); $result = $this->checkUserAllWikis( $user, $subnet );
if ( $result === self::USER_KNOWN ) {
return true; $this->log->debug( 'Checking user {user} from {subnet} (result so far: {soFar}): {result}',
} [
'function' => __METHOD__,
'user' => $user->getName(),
'subnet' => $subnet,
'result' => $result,
'soFar' => json_encode( $resultSoFar ),
]
);
if ( $resultSoFar !== null ) { if ( $resultSoFar !== null ) {
$result = $this->mergeResults( $result, $resultSoFar ); $result = $this->mergeResults( $result, $resultSoFar );
@ -186,7 +193,7 @@ class LoginNotify implements LoggerAwareInterface {
return true; return true;
} }
return false; return $result === self::USER_KNOWN;
} }
/** /**
@ -640,10 +647,20 @@ class LoginNotify implements LoggerAwareInterface {
$this->config->get( 'LoginNotifyAttemptsNewIP' ), $this->config->get( 'LoginNotifyAttemptsNewIP' ),
$this->config->get( 'LoginNotifyExpiryNewIP' ) $this->config->get( 'LoginNotifyExpiryNewIP' )
); );
$message = '{count} failed login attempts for {user} from an unknown system';
if ( $count ) { if ( $count ) {
$this->incrStats( 'fail.unknown.notifications' ); $this->incrStats( 'fail.unknown.notifications' );
$this->sendNotice( $user, 'login-fail-new', $count ); $this->sendNotice( $user, 'login-fail-new', $count );
$message .= ', sending notification';
} }
$this->log->debug( $message,
[
'function' => __METHOD__,
'count' => $count,
'user' => $user->getName(),
]
);
} }
/** /**
@ -799,7 +816,15 @@ class LoginNotify implements LoggerAwareInterface {
*/ */
public function sendSuccessNoticeDeferred( User $user, $subnet, $resultSoFar ) { public function sendSuccessNoticeDeferred( User $user, $subnet, $resultSoFar ) {
$isKnown = $this->isKnownSystemSlow( $user, $subnet, $resultSoFar ); $isKnown = $this->isKnownSystemSlow( $user, $subnet, $resultSoFar );
if ( !$isKnown ) { if ( $isKnown ) {
$this->log->debug( 'Found data for user {user} from {subnet}',
[
'function' => __METHOD__,
'user' => $user->getName(),
'subnet' => $subnet,
]
);
} else {
$this->incrStats( 'success.notifications' ); $this->incrStats( 'success.notifications' );
$this->sendNotice( $user, 'login-success' ); $this->sendNotice( $user, 'login-success' );
} }