IAlex has uploaded a new change for review. https://gerrit.wikimedia.org/r/118937
Change subject: New 'profileerror' log group for profiling errors ...................................................................... New 'profileerror' log group for profiling errors Easier to catch them than if they are in the default debug log. Added Profiler::debugGroup() as wrapper to wfDebugLog(), as there already is Profiler::debug() for wfDebug(), so that there won't be a fatal error if the error happens before the inclusion of GlobalFunctions.php and converted other calls to wfDebugLog() to use it. Change-Id: Ie8481a2e13a94efa0248dd5a36b6b1a22811817e --- M includes/profiler/Profiler.php M includes/profiler/ProfilerMwprof.php M includes/profiler/ProfilerSimple.php 3 files changed, 30 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/37/118937/1 diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index 235a5ad..a26ef68 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -227,15 +227,17 @@ $bit = array_pop( $this->mWorkStack ); if ( !$bit ) { - $this->debug( "Profiling error, !\$bit: $functionname\n" ); + $this->debugGroup( 'profileerror', "Profiling error, !\$bit: $functionname" ); } else { if ( $functionname == 'close' ) { - $message = "Profile section ended by close(): {$bit[0]}"; - $this->debug( "$message\n" ); - $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 ); + if ( $bit[0] != '-total' ) { + $message = "Profile section ended by close(): {$bit[0]}"; + $this->debugGroup( 'profileerror', $message ); + $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 ); + } } elseif ( $bit[0] != $functionname ) { $message = "Profiling error: in({$bit[0]}), out($functionname)"; - $this->debug( "$message\n" ); + $this->debugGroup( 'profileerror', $message ); $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 ); } $bit[] = $time; @@ -324,7 +326,7 @@ list( $method, $realtime ) = $info; $msg .= sprintf( "%d\t%.6f\t%s\n", $i, $realtime, $method ); } - wfDebugLog( 'DBPerformance', $msg ); + $this->debugGroup( 'DBPerformance', $msg ); } unset( $this->mDBTrxHoldingLocks[$name] ); unset( $this->mDBTrxMethodTimes[$name] ); @@ -721,6 +723,18 @@ } /** + * Add an entry in the debug log group + * + * @param string $group Group to send the message to + * @param string $s to output + */ + function debugGroup( $group, $s ) { + if ( function_exists( 'wfDebugLog' ) ) { + wfDebugLog( $group, $s ); + } + } + + /** * Get the content type sent out to the client. * Used for profilers that output instead of store data. * @return string diff --git a/includes/profiler/ProfilerMwprof.php b/includes/profiler/ProfilerMwprof.php index e81c6ec..5ecfc21 100644 --- a/includes/profiler/ProfilerMwprof.php +++ b/includes/profiler/ProfilerMwprof.php @@ -90,7 +90,7 @@ // Check for unbalanced profileIn / profileOut calls. // Bad entries are logged but not sent. if ( $inName !== $outName ) { - wfDebugLog( 'ProfilerUnbalanced', json_encode( array( $inName, $outName ) ) ); + $this->debugGroup( 'ProfilerUnbalanced', json_encode( array( $inName, $outName ) ) ); return; } diff --git a/includes/profiler/ProfilerSimple.php b/includes/profiler/ProfilerSimple.php index ee92c17..7d78e36 100644 --- a/includes/profiler/ProfilerSimple.php +++ b/includes/profiler/ProfilerSimple.php @@ -102,17 +102,18 @@ list( $ofname, /* $ocount */, $ortime, $octime ) = array_pop( $this->mWorkStack ); if ( !$ofname ) { - $this->debug( "Profiling error: $functionname\n" ); + $this->debugGroup( 'profileerror', "Profiling error: $functionname" ); } else { if ( $functionname == 'close' ) { - $message = "Profile section ended by close(): {$ofname}"; - $functionname = $ofname; - $this->debug( "$message\n" ); - $this->mCollated[$message] = $this->errorEntry; - } - elseif ( $ofname != $functionname ) { + if ( $ofname != '-total' ) { + $message = "Profile section ended by close(): {$ofname}"; + $functionname = $ofname; + $this->debugGroup( 'profileerror', $message ); + $this->mCollated[$message] = $this->errorEntry; + } + } elseif ( $ofname != $functionname ) { $message = "Profiling error: in({$ofname}), out($functionname)"; - $this->debug( "$message\n" ); + $this->debugGroup( 'profileerror', $message ); $this->mCollated[$message] = $this->errorEntry; } $elapsedcpu = $this->getTime( 'cpu' ) - $octime; -- To view, visit https://gerrit.wikimedia.org/r/118937 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie8481a2e13a94efa0248dd5a36b6b1a22811817e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: IAlex <coderev...@emsenhuber.ch> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits