[MediaWiki-commits] [Gerrit] mediawiki...LoginNotify[master]: Even more logging

2017-08-24 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/373680 )

Change subject: Even more logging
..


Even more logging

Bug: T173888
Change-Id: I7f9f3cf0657af100c6ae3a8b2bfb5206b86514eb
---
M includes/LoginNotify.php
1 file changed, 30 insertions(+), 5 deletions(-)

Approvals:
  Niharika29: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/LoginNotify.php b/includes/LoginNotify.php
index e8a527e..06376f1 100644
--- a/includes/LoginNotify.php
+++ b/includes/LoginNotify.php
@@ -161,9 +161,16 @@
 */
private function isKnownSystemSlow( User $user, $subnet, $resultSoFar = 
null ) {
$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 ) {
$result = $this->mergeResults( $result, $resultSoFar );
@@ -186,7 +193,7 @@
return true;
}
 
-   return false;
+   return $result === self::USER_KNOWN;
}
 
/**
@@ -640,10 +647,20 @@
$this->config->get( 'LoginNotifyAttemptsNewIP' ),
$this->config->get( 'LoginNotifyExpiryNewIP' )
);
+   $message = '{count} failed login attempts for {user} from an 
unknown system';
if ( $count ) {
$this->incrStats( 'fail.unknown.notifications' );
$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 @@
 */
public function sendSuccessNoticeDeferred( User $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->sendNotice( $user, 'login-success' );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/373680
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7f9f3cf0657af100c6ae3a8b2bfb5206b86514eb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/LoginNotify
Gerrit-Branch: master
Gerrit-Owner: MaxSem 
Gerrit-Reviewer: MaxSem 
Gerrit-Reviewer: Niharika29 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...LoginNotify[master]: Even more logging

2017-08-24 Thread MaxSem (Code Review)
MaxSem has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373680 )

Change subject: Even more logging
..

Even more logging

Bug: T173888
Change-Id: I7f9f3cf0657af100c6ae3a8b2bfb5206b86514eb
---
M includes/LoginNotify.php
1 file changed, 29 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LoginNotify 
refs/changes/80/373680/1

diff --git a/includes/LoginNotify.php b/includes/LoginNotify.php
index e8a527e..ef6575d 100644
--- a/includes/LoginNotify.php
+++ b/includes/LoginNotify.php
@@ -161,13 +161,19 @@
 */
private function isKnownSystemSlow( User $user, $subnet, $resultSoFar = 
null ) {
$result = $this->checkUserAllWikis( $user, $subnet );
-   if ( $result === self::USER_KNOWN ) {
-   return true;
-   }
 
if ( $resultSoFar !== null ) {
$result = $this->mergeResults( $result, $resultSoFar );
}
+
+   $this->log->debug( 'Checking user {user} from {subnet}: 
{result}',
+   [
+   'function' => __METHOD__,
+   'user' => $user->getName(),
+   'subnet' => $subnet,
+   'result' => $result,
+   ]
+   );
 
// If we have no check user data for the user, and there was
// no cookie supplied, just pass the user in, since we don't 
have
@@ -186,7 +192,7 @@
return true;
}
 
-   return false;
+   return $result === self::USER_KNOWN;
}
 
/**
@@ -640,10 +646,20 @@
$this->config->get( 'LoginNotifyAttemptsNewIP' ),
$this->config->get( 'LoginNotifyExpiryNewIP' )
);
+   $message = '{count} failed login attempts for {user} from an 
unknown system';
if ( $count ) {
$this->incrStats( 'fail.unknown.notifications' );
$this->sendNotice( $user, 'login-fail-new', $count );
+   $message .= ', sending notification';
}
+
+   $this->log->debug( $message,
+   [
+   'function' => __METHOD__,
+   'count' => $count,
+   'user' => $user->getName(),
+   ]
+   );
}
 
/**
@@ -799,7 +815,15 @@
 */
public function sendSuccessNoticeDeferred( User $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->sendNotice( $user, 'login-success' );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/373680
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f9f3cf0657af100c6ae3a8b2bfb5206b86514eb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LoginNotify
Gerrit-Branch: master
Gerrit-Owner: MaxSem 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits