jenkins-bot has submitted this change and it was merged.
Change subject: LegacyLogger: Be consistent about converting log levels to int
......................................................................
LegacyLogger: Be consistent about converting log levels to int
Normalize $level arguments to integers early to avoid confusion later
about what type the argument is.
Change-Id: I7305c0514f4383ec552afea2deb0e3fc6ba3fe8a
---
M includes/debug/logger/LegacyLogger.php
1 file changed, 9 insertions(+), 6 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/debug/logger/LegacyLogger.php
b/includes/debug/logger/LegacyLogger.php
index 0ca20bb..4d7c84d 100644
--- a/includes/debug/logger/LegacyLogger.php
+++ b/includes/debug/logger/LegacyLogger.php
@@ -94,6 +94,9 @@
* @return null
*/
public function log( $level, $message, array $context = [] ) {
+ if ( is_string( $level ) ) {
+ $level = self::$levelMapping[$level];
+ }
if ( $this->channel === 'DBQuery' && isset( $context['method'] )
&& isset( $context['master'] ) && isset(
$context['runtime'] )
) {
@@ -102,8 +105,7 @@
}
if ( isset( self::$dbChannels[$this->channel] )
- && isset( self::$levelMapping[$level] )
- && self::$levelMapping[$level] >=
self::$levelMapping[LogLevel::ERROR]
+ && $level >= self::$levelMapping[LogLevel::ERROR]
) {
// Format and write DB errors to the legacy locations
$effectiveChannel = 'wfLogDBError';
@@ -127,13 +129,17 @@
*
* @param string $channel
* @param string $message
- * @param string|int $level \Psr\Log\LogEvent constant or Monlog level
int
+ * @param string|int $level \Psr\Log\LogEvent constant or Monolog level
int
* @param array $context
* @return bool True if message should be sent to disk/network, false
* otherwise
*/
public static function shouldEmit( $channel, $message, $level, $context
) {
global $wgDebugLogFile, $wgDBerrorLog, $wgDebugLogGroups;
+
+ if ( is_string( $level ) ) {
+ $level = self::$levelMapping[$level];
+ }
if ( $channel === 'wfLogDBError' ) {
// wfLogDBError messages are emitted if a database log
location is
@@ -162,9 +168,6 @@
}
if ( isset( $logConfig['level'] ) ) {
- if ( is_string( $level ) ) {
- $level =
self::$levelMapping[$level];
- }
$shouldEmit = $level >=
self::$levelMapping[$logConfig['level']];
}
} else {
--
To view, visit https://gerrit.wikimedia.org/r/313635
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7305c0514f4383ec552afea2deb0e3fc6ba3fe8a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits