jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/404146 )

Change subject: Convert SocialProfile to use PSR-3 structured logging
......................................................................


Convert SocialProfile to use PSR-3 structured logging

This patch converts SocialProfile to use structured logging,
which allows it to properly follow the PSR-3 standard.

This also helps to replace calls of the global wfDebug function,
and creates our own debugging channel.

References:
 - https://www.mediawiki.org/wiki/Manual:Structured_logging
 - http://www.php-fig.org/psr/psr-3/

Change-Id: Ice1a3f5ae1175ce706f8fed25792f10883681af2
---
M SystemGifts/SpecialSystemGiftManagerLogo.php
M SystemGifts/UserSystemGiftsClass.php
M UserActivity/SiteActivityHook.php
M UserBoard/UserBoardClass.php
M UserGifts/SpecialGiftManagerLogo.php
M UserGifts/UserGiftsClass.php
M UserProfile/UserProfilePage.php
M UserRelationship/UserRelationshipClass.php
M UserStats/TopFansByStat.php
M UserStats/TopFansRecent.php
M UserStats/TopUsers.php
M UserStats/UserStats.php
M UserStats/UserStatsTrack.php
13 files changed, 226 insertions(+), 43 deletions(-)

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



diff --git a/SystemGifts/SpecialSystemGiftManagerLogo.php 
b/SystemGifts/SpecialSystemGiftManagerLogo.php
index 38bbdd4..368e551 100644
--- a/SystemGifts/SpecialSystemGiftManagerLogo.php
+++ b/SystemGifts/SpecialSystemGiftManagerLogo.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * A special page to upload images for system gifts (awards).
  * This is mostly copied from an old version of Special:Upload and changed a
@@ -75,7 +78,12 @@
                $this->mUploadCopyStatus = $request->getText( 
'wpUploadCopyStatus' );
                $this->mUploadSource = $request->getText( 'wpUploadSource' );
                $this->mWatchthis = $request->getBool( 'wpWatchthis' );
-               wfDebug( __METHOD__ . ": watchthis is: '$this->mWatchthis'\n" );
+
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "{method}: watchthis is: '{watchthis}'\n", [
+                       'method' => __METHOD__,
+                       'watchthis' => $this->mWatchthis
+               ] );
 
                $this->mAction = $request->getVal( 'action' );
                $this->mSessionKey = $request->getInt( 'wpSessionKey' );
@@ -722,7 +730,11 @@
                        return Status::newFatal( 'uploadvirus', 
htmlspecialchars( $virus ) );
                }
 
-               wfDebug( __METHOD__ . ": all clear; passing.\n" );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "{method}: all clear; passing.\n", [
+                       'method' => __METHOD__
+               ] );
+
                return Status::newGood();
        }
 }
diff --git a/SystemGifts/UserSystemGiftsClass.php 
b/SystemGifts/UserSystemGiftsClass.php
index 1824918..9f820cc 100644
--- a/SystemGifts/UserSystemGiftsClass.php
+++ b/SystemGifts/UserSystemGiftsClass.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * Class for managing awards (a.k.a system gifts)
  */
@@ -290,7 +293,12 @@
                $key = $wgMemc->makeKey( 'system_gifts', 'new_count', $user_id 
);
                $data = $wgMemc->get( $key );
                if ( $data != '' ) {
-                       wfDebug( "Got new award count of $data for id $user_id 
from cache\n" );
+                       $logger = LoggerFactory::getInstance( 'SocialProfile' );
+                       $logger->debug( "Got new award count of {data} for 
{user_id} from cache\n", [
+                               'data' => $data,
+                               'user_id' => $user_id
+                       ] );
+
                        return $data;
                }
        }
@@ -326,7 +334,10 @@
         * @return Integer: amount of new system gifts
         */
        static function getNewSystemGiftCountDB( $user_id ) {
-               wfDebug( "Got new award count for id $user_id from DB\n" );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "Got new award count for id {user_id} from 
DB\n", [
+                       'user_id' => $user_id
+               ] );
 
                global $wgMemc;
                $key = $wgMemc->makeKey( 'system_gifts', 'new_count', $user_id 
);
diff --git a/UserActivity/SiteActivityHook.php 
b/UserActivity/SiteActivityHook.php
index 65f7942..1b8fbd4 100644
--- a/UserActivity/SiteActivityHook.php
+++ b/UserActivity/SiteActivityHook.php
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\Logger\LoggerFactory;
+
 class SiteActivityHook {
 
        /**
@@ -25,15 +27,19 @@
 
                $key = $wgMemc->makeKey( 'site_activity', 'all', $fixedLimit );
                $data = $wgMemc->get( $key );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+
                if ( !$data ) {
-                       wfDebug( "Got site activity from DB\n" );
+                       $logger->debug( "Got new site activity from DB\n" );
+
                        $rel = new UserActivity( '', 'ALL', $fixedLimit );
 
                        $rel->setActivityToggle( 'show_votes', 0 );
                        $activity = $rel->getActivityListGrouped();
                        $wgMemc->set( $key, $activity, 60 * 2 );
                } else {
-                       wfDebug( "Got site activity from cache\n" );
+                       $logger->debug( "Got site activity from cache\n" );
+
                        $activity = $data;
                }
 
diff --git a/UserBoard/UserBoardClass.php b/UserBoard/UserBoardClass.php
index 2b59a45..5135fc0 100644
--- a/UserBoard/UserBoardClass.php
+++ b/UserBoard/UserBoardClass.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * Functions for managing user board data
  */
@@ -148,8 +151,14 @@
                global $wgMemc;
                $key = $wgMemc->makeKey( 'user', 'newboardmessage', $user_id );
                $data = $wgMemc->get( $key );
+
                if ( $data != '' ) {
-                       wfDebug( "Got new message count of $data for id 
$user_id from cache\n" );
+                       $logger = LoggerFactory::getInstance( 'SocialProfile' );
+                       $logger->debug( "Got new message count of {data} for id 
{user_id} from cache\n", [
+                               'data' => $data,
+                               'user_id' => $user_id
+                       ] );
+
                        return $data;
                }
        }
@@ -165,7 +174,10 @@
        static function getNewMessageCountDB( $user_id ) {
                global $wgMemc;
 
-               wfDebug( "Got new message count for id $user_id from DB\n" );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "Got new message count for id {user_id} from 
DB\n", [
+                       'user_id' => $user_id
+               ] );
 
                $key = $wgMemc->makeKey( 'user', 'newboardmessage', $user_id );
                $newCount = 0;
diff --git a/UserGifts/SpecialGiftManagerLogo.php 
b/UserGifts/SpecialGiftManagerLogo.php
index e9169e8..b36b760 100644
--- a/UserGifts/SpecialGiftManagerLogo.php
+++ b/UserGifts/SpecialGiftManagerLogo.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * A special page to upload images for gifts.
  * This is mostly copied from an old version of Special:Upload and changed a
@@ -77,7 +80,12 @@
                $this->mUploadCopyStatus = $request->getText( 
'wpUploadCopyStatus' );
                $this->mUploadSource = $request->getText( 'wpUploadSource' );
                $this->mWatchthis = $request->getBool( 'wpWatchthis' );
-               wfDebug( __METHOD__ . ": watchthis is: '$this->mWatchthis'\n" );
+
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "{method}: watchthis is: '{watchthis}'\n", [
+                       'method' => __METHOD__,
+                       'watchthis' => $this->mWatchthis
+               ] );
 
                $this->mAction = $request->getVal( 'action' );
                $this->mSessionKey = $request->getInt( 'wpSessionKey' );
@@ -724,7 +732,11 @@
                        return Status::newFatal( 'uploadvirus', 
htmlspecialchars( $virus ) );
                }
 
-               wfDebug( __METHOD__ . ": all clear; passing.\n" );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "{method}: all clear; passing.\n", [
+                       'method' => __METHOD__
+               ] );
+
                return Status::newGood();
        }
 }
diff --git a/UserGifts/UserGiftsClass.php b/UserGifts/UserGiftsClass.php
index 45b928e..01c74f7 100644
--- a/UserGifts/UserGiftsClass.php
+++ b/UserGifts/UserGiftsClass.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * UserGifts class
  * @todo document
@@ -269,7 +272,12 @@
                $key = $wgMemc->makeKey( 'user_gifts', 'new_count', $user_id );
                $data = $wgMemc->get( $key );
                if ( $data != '' ) {
-                       wfDebug( "Got new gift count of $data for id $user_id 
from cache\n" );
+                       $logger = LoggerFactory::getInstance( 'SocialProfile' );
+                       $logger->debug( "Got new gift count of {data} for id 
{user_id} from cache\n", [
+                               'data' => $data,
+                               'user_id' => $user_id
+                       ] );
+
                        return $data;
                }
        }
@@ -304,7 +312,10 @@
         * @return Integer: amount of new gifts
         */
        static function getNewGiftCountDB( $user_id ) {
-               wfDebug( "Got new gift count for id $user_id from DB\n" );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "Got new gift count for id {user_id} from 
DB\n", [
+                       'user_id' => $user_id
+               ] );
 
                global $wgMemc;
                $key = $wgMemc->makeKey( 'user_gifts', 'new_count', $user_id );
diff --git a/UserProfile/UserProfilePage.php b/UserProfile/UserProfilePage.php
index e4de315..4bb2d67 100644
--- a/UserProfile/UserProfilePage.php
+++ b/UserProfile/UserProfilePage.php
@@ -1,4 +1,6 @@
 <?php
+
+use MediaWiki\Logger\LoggerFactory;
 use MediaWiki\MediaWikiServices;
 
 /**
@@ -83,6 +85,7 @@
        function view() {
                $context = $this->getContext();
                $out = $context->getOutput();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                $out->setPageTitle( $this->mTitle->getPrefixedText() );
 
@@ -115,7 +118,9 @@
                $userProfilePage = $this;
 
                if ( !Hooks::run( 'UserProfileBeginLeft', array( 
&$userProfilePage ) ) ) {
-                       wfDebug( __METHOD__ . ": UserProfileBeginLeft messed up 
profile!\n" );
+                       $logger->debug( "{method}: UserProfileBeginLeft messed 
up profile!\n", [
+                               'method' => __METHOD__
+                       ] );
                }
 
                $out->addHTML( $this->getRelationships( $this->user_name, 1 ) );
@@ -128,31 +133,39 @@
                $out->addHTML( $this->getUserStats( $this->user_id, 
$this->user_name ) );
 
                if ( !Hooks::run( 'UserProfileEndLeft', array( 
&$userProfilePage ) ) ) {
-                       wfDebug( __METHOD__ . ": UserProfileEndLeft messed up 
profile!\n" );
+                       $logger->debug( "{method}: UserProfileEndLeft messed up 
profile!\n", [
+                               'method' => __METHOD__
+                       ] );
                }
 
                $out->addHTML( '</div>' );
 
-               wfDebug( "profile start right\n" );
+               $logger->debug( "profile start right\n" );
 
                // Right side
                $out->addHTML( '<div id="user-page-right" class="clearfix">' );
 
                if ( !Hooks::run( 'UserProfileBeginRight', array( 
&$userProfilePage ) ) ) {
-                       wfDebug( __METHOD__ . ": UserProfileBeginRight messed 
up profile!\n" );
+                       $logger->debug( "{method}: UserProfileBeginRight messed 
up profile!\n", [
+                               'method' => __METHOD__
+                       ] );
                }
 
                $out->addHTML( $this->getPersonalInfo( $this->user_id, 
$this->user_name ) );
                $out->addHTML( $this->getActivity( $this->user_name ) );
                // Hook for BlogPage
                if ( !Hooks::run( 'UserProfileRightSideAfterActivity', array( 
$this ) ) ) {
-                       wfDebug( __METHOD__ . ": 
UserProfileRightSideAfterActivity hook messed up profile!\n" );
+                       $logger->debug( "{method}: 
UserProfileRightSideAfterActivity hook messed up profile!\n", [
+                               'method' => __METHOD__
+                       ] );
                }
                $out->addHTML( $this->getCasualGames( $this->user_id, 
$this->user_name ) );
                $out->addHTML( $this->getUserBoard( $this->user_id, 
$this->user_name ) );
 
                if ( !Hooks::run( 'UserProfileEndRight', array( 
&$userProfilePage ) ) ) {
-                       wfDebug( __METHOD__ . ": UserProfileEndRight messed up 
profile!\n" );
+                       $logger->debug( "{method}: UserProfileEndRight messed 
up profile!\n", [
+                               'method' => __METHOD__
+                       ] );
                }
 
                $out->addHTML( '</div><div class="visualClear"></div>' );
@@ -257,16 +270,23 @@
                global $wgMemc;
 
                $polls = array();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                // Try cache
                $key = $wgMemc->makeKey( 'user', 'profile', 'polls', 
$this->user_id );
                $data = $wgMemc->get( $key );
 
                if( $data ) {
-                       wfDebug( "Got profile polls for user {$this->user_id} 
from cache\n" );
+                       $logger->debug( "Got profile polls for user {user_id} 
from cache\n", [
+                               'user_id' => $this->user_id
+                       ] );
+
                        $polls = $data;
                } else {
-                       wfDebug( "Got profile polls for user {$this->user_id} 
from DB\n" );
+                       $logger->debug( "Got profile polls for user {user_id} 
from DB\n", [
+                               'user_id' => $this->user_id
+                       ] );
+
                        $dbr = wfGetDB( DB_REPLICA );
                        $res = $dbr->select(
                                array( 'poll_question', 'page' ),
@@ -297,16 +317,23 @@
                global $wgMemc;
 
                $quiz = array();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                // Try cache
                $key = $wgMemc->makeKey( 'user', 'profile', 'quiz', 
$this->user_id );
                $data = $wgMemc->get( $key );
 
                if( $data ) {
-                       wfDebug( "Got profile quizzes for user {$this->user_id} 
from cache\n" );
+                       $logger->debug( "Got profile quizzes for user {user_id} 
from cache\n", [
+                               'user_id' => $this->user_id
+                       ] );
+
                        $quiz = $data;
                } else {
-                       wfDebug( "Got profile quizzes for user {$this->user_id} 
from DB\n" );
+                       $logger->debug( "Got profile quizzes for user {user_id} 
from DB\n", [
+                               'user_id' => $this->user_id
+                       ] );
+
                        $dbr = wfGetDB( DB_REPLICA );
                        $res = $dbr->select(
                                'quizgame_questions',
@@ -344,15 +371,22 @@
                global $wgMemc;
 
                $pics = array();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                // Try cache
                $key = $wgMemc->makeKey( 'user', 'profile', 'picgame', 
$this->user_id );
                $data = $wgMemc->get( $key );
                if( $data ) {
-                       wfDebug( "Got profile picgames for user 
{$this->user_id} from cache\n" );
+                       $logger->debug( "Got profile picgames for user 
{user_id} from cache\n", [
+                               'user_id' => $this->user_id
+                       ] );
+
                        $pics = $data;
                } else {
-                       wfDebug( "Got profile picgames for user 
{$this->user_id} from DB\n" );
+                       $logger->debug( "Got profile picgames for user 
{user_id} from DB\n", [
+                               'user_id' => $this->user_id
+                       ] );
+
                        $dbr = wfGetDB( DB_REPLICA );
                        $res = $dbr->select(
                                'picturegame_images',
@@ -960,7 +994,11 @@
                }
                $avatar = new wAvatar( $this->user_id, 'l' );
 
-               wfDebug( 'profile type: ' . $profile_data['user_page_type'] . 
"\n" );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "profile type: {user_profile_type} \n", [
+                       'user_profile_type' => $profile_data['user_page_type']
+               ] );
+
                $output = '';
 
                // Show the link for changing user page type for the user whose 
page
@@ -1170,7 +1208,12 @@
                        $friends = $rel->getRelationshipList( $rel_type, $count 
);
                        $wgMemc->set( $key, $friends );
                } else {
-                       wfDebug( "Got profile relationship type {$rel_type} for 
user {$user_name} from cache\n" );
+                       $logger = LoggerFactory::getInstance( 'SocialProfile' );
+                       $logger->debug( "Got profile relationship type 
{rel_type} for user {user_name} from cache\n", [
+                               'rel_type' => $rel_type,
+                               'user_name' => $user_name
+                       ] );
+
                        $friends = $data;
                }
 
@@ -1428,6 +1471,7 @@
 
                $context = $this->getContext();
                $user = $context->getUser();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                // If not enabled in site settings, don't display
                if ( $wgUserProfileDisplay['gifts'] == false ) {
@@ -1445,11 +1489,16 @@
                $data = $wgMemc->get( $key );
 
                if ( !$data ) {
-                       wfDebug( "Got profile gifts for user {$user_name} from 
DB\n" );
+                       $logger->debug( "Got profile gifts for user {user_name} 
from DB\n", [
+                               'user_name' => $user_name
+                       ] );
+
                        $gifts = $g->getUserGiftList( 0, 4 );
                        $wgMemc->set( $key, $gifts, 60 * 60 * 4 );
                } else {
-                       wfDebug( "Got profile gifts for user {$user_name} from 
cache\n" );
+                       $logger->debug( "Got profile gifts for user {user_name} 
from cache\n", [
+                               'user_name' => $user_name
+                       ] );
                        $gifts = $data;
                }
 
@@ -1520,6 +1569,7 @@
 
                $context = $this->getContext();
                $user = $context->getUser();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                // If not enabled in site settings, don't display
                if ( $wgUserProfileDisplay['awards'] == false ) {
@@ -1535,11 +1585,17 @@
                $sg_key = $wgMemc->makeKey( 'user', 'profile', 'system_gifts', 
"{$sg->user_id}" );
                $data = $wgMemc->get( $sg_key );
                if ( !$data ) {
-                       wfDebug( "Got profile awards for user {$user_name} from 
DB\n" );
+                       $logger->debug( "Got profile awards for user 
{user_name} from DB\n", [
+                               'user_name' => $user_name
+                       ] );
+
                        $system_gifts = $sg->getUserGiftList( 0, 4 );
                        $wgMemc->set( $sg_key, $system_gifts, 60 * 60 * 4 );
                } else {
-                       wfDebug( "Got profile awards for user {$user_name} from 
cache\n" );
+                       $logger->debug( "Got profile awards for user 
{user_name} from cache\n", [
+                               'user_name' => $user_name
+                       ] );
+
                        $system_gifts = $data;
                }
 
@@ -1747,13 +1803,20 @@
                /*
                $key = $wgMemc->makeKey( 'user', 'profile', 'fanboxes', 
"{$f->user_id}" );
                $data = $wgMemc->get( $key );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                if ( !$data ) {
-                       wfDebug( "Got profile fanboxes for user {$user_name} 
from DB\n" );
+                       $logger->debug( "Got profile fanboxes for user 
{user_name} from DB\n", [
+                               'user_name' => $user_name
+                       ] );
+
                        $fanboxes = $f->getUserFanboxes( 0, 10 );
                        $wgMemc->set( $key, $fanboxes );
                } else {
-                       wfDebug( "Got profile fanboxes for user {$user_name} 
from cache\n" );
+                       $logger->debug( "Got profile fanboxes for user 
{user_name} from cache\n", [
+                               'user_name' => $user_name
+                       ] );
+
                        $fanboxes = $data;
                }
                */
diff --git a/UserRelationship/UserRelationshipClass.php 
b/UserRelationship/UserRelationshipClass.php
index 66fb376..ec21da4 100644
--- a/UserRelationship/UserRelationshipClass.php
+++ b/UserRelationship/UserRelationshipClass.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * Functions for managing relationship data
  */
@@ -615,7 +618,11 @@
        static function getOpenRequestCountDB( $userId, $relType ) {
                global $wgMemc;
 
-               wfDebug( "Got open request count (type={$relType}) for id 
$userId from DB\n" );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "Got open request count (type={relType}) for id 
{userId} from DB\n", [
+                       'rel_type' => $relType,
+                       'user_id' => $userId
+               ] );
 
                $key = $wgMemc->makeKey( 'user_relationship', 'open_request', 
$relType, $userId );
                $dbr = wfGetDB( DB_REPLICA );
@@ -653,7 +660,13 @@
                $key = $wgMemc->makeKey( 'user_relationship', 'open_request', 
$relType, $userId );
                $data = $wgMemc->get( $key );
                if ( $data != '' ) {
-                       wfDebug( "Got open request count of $data 
(type={$relType}) for id $userId from cache\n" );
+                       $logger = LoggerFactory::getInstance( 'SocialProfile' );
+                       $logger->debug( "Got open request count of {data} 
(type={relType}) for id {userId} from cache\n", [
+                               'data' => $data,
+                               'rel_type' => $relType,
+                               'user_id' => $userId
+                       ] );
+
                        return $data;
                }
        }
diff --git a/UserStats/TopFansByStat.php b/UserStats/TopFansByStat.php
index 0bdd7db..f565fde 100644
--- a/UserStats/TopFansByStat.php
+++ b/UserStats/TopFansByStat.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * Special page that shows the top users for a given statistic, i.e.
  * "users with the most friends" or "users with the most votes".
@@ -29,6 +32,7 @@
                $lang = $this->getLanguage();
                $out = $this->getOutput();
                $request = $this->getRequest();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                // Set the page title, robot policies, etc.
                $this->setHeaders();
@@ -68,10 +72,17 @@
                $data = $wgMemc->get( $key );
 
                if ( $data != '' ) {
-                       wfDebug( "Got top users by {$statistic} ({$count}) from 
cache\n" );
+                       $logger->debug( "Got top users by {statistic} ({count}) 
from cache\n", [
+                               'statistic' => $statistic,
+                               'count' => $count
+                       ] );
+
                        $user_list = $data;
                } else {
-                       wfDebug( "Got top users by {$statistic} ({$count}) from 
DB\n" );
+                       $logger->debug( "Got top users by {statistic} ({count}) 
from DB\n", [
+                               'statistic' => $statistic,
+                               'count' => $count
+                       ] );
 
                        $params['ORDER BY'] = "{$column} DESC";
                        $params['LIMIT'] = $count;
diff --git a/UserStats/TopFansRecent.php b/UserStats/TopFansRecent.php
index 0d3d114..aa0ad7e 100644
--- a/UserStats/TopFansRecent.php
+++ b/UserStats/TopFansRecent.php
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\Logger\LoggerFactory;
+
 class TopFansRecent extends UnlistedSpecialPage {
 
        /**
@@ -33,6 +35,7 @@
                $out = $this->getOutput();
                $request = $this->getRequest();
                $user = $this->getUser();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                // Set the page title, robot policies, etc.
                $this->setHeaders();
@@ -68,10 +71,17 @@
                $data = $wgMemc->get( $key );
 
                if ( $data != '' ) {
-                       wfDebug( "Got top users by {$period} points ({$count}) 
from cache\n" );
+                       $logger->debug( "Got top users by {period} points 
({count}) from cache\n", [
+                               'period' => $period,
+                               'count' => $count
+                       ] );
+
                        $user_list = $data;
                } else {
-                       wfDebug( "Got top users by {$period} points ({$count}) 
from DB\n" );
+                       $logger->debug( "Got top users by {period} points 
({count}) from DB\n", [
+                               'period' => $period,
+                               'count' => $count
+                       ] );
 
                        $params['ORDER BY'] = 'up_points DESC';
                        $params['LIMIT'] = $count;
diff --git a/UserStats/TopUsers.php b/UserStats/TopUsers.php
index 4bfa373..ebf0358 100644
--- a/UserStats/TopUsers.php
+++ b/UserStats/TopUsers.php
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\Logger\LoggerFactory;
+
 class TopUsersPoints extends SpecialPage {
 
        /**
@@ -19,6 +21,7 @@
 
                $linkRenderer = $this->getLinkRenderer();
                $out = $this->getOutput();
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
 
                // Load CSS
                $out->addModuleStyles( 'ext.socialprofile.userstats.css' );
@@ -38,10 +41,15 @@
                $data = $wgMemc->get( $key );
 
                if ( $data != '' ) {
-                       wfDebug( "Got top users by points ({$count}) from 
cache\n" );
+                       $logger->debug( "Got top users by points ({count}) from 
cache\n", [
+                               'count' => $count
+                       ] );
+
                        $user_list = $data;
                } else {
-                       wfDebug( "Got top users by points ({$count}) from DB\n" 
);
+                       $logger->debug( "Got top users by points ({count}) from 
DB\n", [
+                               'count' => $count
+                       ] );
 
                        $params['ORDER BY'] = 'stats_total_points DESC';
                        $params['LIMIT'] = $count;
diff --git a/UserStats/UserStats.php b/UserStats/UserStats.php
index 42aa76b..b32731e 100644
--- a/UserStats/UserStats.php
+++ b/UserStats/UserStats.php
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\Logger\LoggerFactory;
+
 class UserStats {
        /**
         * Constructor
@@ -55,7 +57,11 @@
                $key = wfMemcKey( 'user', 'stats', $this->user_id );
                $data = $wgMemc->get( $key );
                if ( $data ) {
-                       wfDebug( "Got user stats for {$this->user_name} from 
cache\n" );
+                       $logger = LoggerFactory::getInstance( 'SocialProfile' );
+                       $logger->debug( "Got user stats for {user_name} from 
cache\n", [
+                               'user_name' => $this->user_name
+                       ] );
+
                        return $data;
                }
        }
@@ -66,7 +72,11 @@
        public function getUserStatsDB() {
                global $wgMemc;
 
-               wfDebug( "Got user stats for {$this->user_name} from DB\n" );
+               $logger = LoggerFactory::getInstance( 'SocialProfile' );
+               $logger->debug( "Got user stats for {user_name} from DB\n", [
+                       'user_name' => $this->user_name
+               ] );
+
                $dbr = wfGetDB( DB_MASTER );
                $res = $dbr->select(
                        'user_stats',
diff --git a/UserStats/UserStatsTrack.php b/UserStats/UserStatsTrack.php
index eeac4ff..eb71a7c 100644
--- a/UserStats/UserStatsTrack.php
+++ b/UserStats/UserStatsTrack.php
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\Logger\LoggerFactory;
+
 class UserStatsTrack {
 
        // for referencing purposes
@@ -154,7 +156,9 @@
                        $data = $wgMemc->get( $key );
 
                        if ( $data ) {
-                               wfDebug( "Got system gift ID from cache\n" );
+                               $logger = LoggerFactory::getInstance( 
'SocialProfile' );
+                               $logger->debug( "Got system gift ID from 
cache\n" );
+
                                $systemGiftID = $data;
                        } else {
                                $g = new SystemGifts();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ice1a3f5ae1175ce706f8fed25792f10883681af2
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/SocialProfile
Gerrit-Branch: master
Gerrit-Owner: SamanthaNguyen <samanthanguyen1...@gmail.com>
Gerrit-Reviewer: Jack Phoenix <ash...@uncyclomedia.co>
Gerrit-Reviewer: Lewis Cawte <le...@lewiscawte.me>
Gerrit-Reviewer: SamanthaNguyen <samanthanguyen1...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to