r74962 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74961‎ | r74962 | r74963 >
Date:19:56, 18 October 2010
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
Make some wfDebug() messages nicer to look at in debug log file.
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/db/LoadBalancer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -248,7 +248,7 @@
249249 }
250250
251251 if ( !$data ) {
252 - wfDebug( "Cache miss for user {$this->mId}\n" );
 252+ wfDebug( "User: cache miss for user {$this->mId}\n" );
253253 # Load from DB
254254 if ( !$this->loadFromDatabase() ) {
255255 # Can't load from ID, user is anonymous
@@ -256,7 +256,7 @@
257257 }
258258 $this->saveToCache();
259259 } else {
260 - wfDebug( "Got user {$this->mId} from cache\n" );
 260+ wfDebug( "User: got user {$this->mId} from cache\n" );
261261 # Restore from cache
262262 foreach ( self::$mCacheVars as $name ) {
263263 $this->$name = $data[$name];
@@ -890,11 +890,11 @@
891891
892892 if ( ( $sName == $this->mName ) && $passwordCorrect ) {
893893 $_SESSION['wsToken'] = $this->mToken;
894 - wfDebug( "Logged in from $from\n" );
 894+ wfDebug( "User: logged in from $from\n" );
895895 return true;
896896 } else {
897897 # Invalid credentials
898 - wfDebug( "Can't log in from $from, invalid credentials\n" );
 898+ wfDebug( "User: can't log in from $from, invalid credentials\n" );
899899 $this->loadDefaults();
900900 return false;
901901 }
@@ -3617,12 +3617,12 @@
36183618
36193619 // Maybe load from the object
36203620 if ( !is_null( $this->mOptionOverrides ) ) {
3621 - wfDebug( "Loading options for user " . $this->getId() . " from override cache.\n" );
 3621+ wfDebug( "User: loading options for user " . $this->getId() . " from override cache.\n" );
36223622 foreach( $this->mOptionOverrides as $key => $value ) {
36233623 $this->mOptions[$key] = $value;
36243624 }
36253625 } else {
3626 - wfDebug( "Loading options for user " . $this->getId() . " from database.\n" );
 3626+ wfDebug( "User: loading options for user " . $this->getId() . " from database.\n" );
36273627 // Load from database
36283628 $dbr = wfGetDB( DB_SLAVE );
36293629
Index: trunk/phase3/includes/db/LoadBalancer.php
@@ -647,12 +647,12 @@
648648 $class = 'Database' . ucfirst( $type );
649649
650650 # Create object
651 - wfDebug( "Connecting to $host $dbname...\n" );
 651+ wfDebug( "Connecting to $host $dbname... " );
652652 $db = new $class( $host, $user, $password, $dbname, 1, $flags );
653653 if ( $db->isOpen() ) {
654 - wfDebug( "Connected\n" );
 654+ wfDebug( "Connected.\n" );
655655 } else {
656 - wfDebug( "Failed\n" );
 656+ wfDebug( "Failed.\n" );
657657 }
658658 $db->setLBInfo( $server );
659659 if ( isset( $server['fakeSlaveLag'] ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r75003Follow up r74962, debug messages should be splitted....hashar06:27, 19 October 2010

Comments

#Comment by Brion VIBBER (talk | contribs)   23:40, 18 October 2010

It's not safe to split a log line over two separate wfDebug() calls; if going to a log server they won't get reassembled together, and if going straight to a logging file, concurrent accesses could cause them to split up unpleasantly, such as having an unrelated line follow on the end of the "... ".

It would be best to have the "Connecting..." and the "Connected."/"Failed." as distinct, self-contained messages if both before and after events need to be logged.

#Comment by Hashar (talk | contribs)   06:29, 19 October 2010

Thanks Brion for the above detailled report! I corrected the split issue and made the Connected/Failed messages self meaningful.

Status & tagging log