jenkins-bot has submitted this change and it was merged.
Change subject: Optional MWLoggerMonologSpi configuration
......................................................................
Optional MWLoggerMonologSpi configuration
Build MWLoggerMonologSpi configuration from $wgDebugLogGroups that will
emit log events as udp2log compatible packets as well as forwarding to
Logstash via a Redis queue. The configuration is built dynamically based
on the existing configuration needed for MWLoggerLegacySpi to avoid
confusion/omission that would be likely with 2 sets of logging
configuration to manage. The $wgDebugLogGroups is still needed to
configure the MWLoggerMonologHandler classes used in the
MWLoggerMonologSpi configuration.
Use is gated by the $wmgUseMonologLogger feature flag in
InitialiseSettings.php that can be used to selectively enable
MWLoggerMonologSpi based logging on a wiki by wiki basis.
Bug: T76759
Change-Id: I720f2cb5975aac40e7c1186c942d9126d67bd190
---
M docroot/noc/createTxtFileSymlinks.sh
M wmf-config/CommonSettings-labs.php
M wmf-config/CommonSettings.php
M wmf-config/logging-labs.php
A wmf-config/logging.php
5 files changed, 103 insertions(+), 1 deletion(-)
Approvals:
BryanDavis: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docroot/noc/createTxtFileSymlinks.sh
b/docroot/noc/createTxtFileSymlinks.sh
index 270177a..9b8095b 100755
--- a/docroot/noc/createTxtFileSymlinks.sh
+++ b/docroot/noc/createTxtFileSymlinks.sh
@@ -23,6 +23,7 @@
jobqueue-eqiad.php
LegalContactPages.php
liquidthreads.php
+ logging.php
logging-labs.php
lucene-common.php
lucene-production.php
diff --git a/wmf-config/CommonSettings-labs.php
b/wmf-config/CommonSettings-labs.php
index 9f4b9c8..478a819 100644
--- a/wmf-config/CommonSettings-labs.php
+++ b/wmf-config/CommonSettings-labs.php
@@ -7,7 +7,6 @@
# Should not be loaded on production
if( $wmfRealm == 'labs' ) { # safe guard
- include( "logging-labs.php" );
// test wiki
if ( $wgDBname == 'testwiki' ) {
diff --git a/wmf-config/CommonSettings.php b/wmf-config/CommonSettings.php
index 5354af1..f87936d 100644
--- a/wmf-config/CommonSettings.php
+++ b/wmf-config/CommonSettings.php
@@ -236,6 +236,11 @@
# Needs to be before db.php
require( "$wmfConfigDir/PrivateSettings.php" );
+# Monolog logging configuration
+wfProfileIn( "$fname-logging" );
+require( getRealmSpecificFilename( "$wmfConfigDir/logging.php" ) );
+wfProfileOut( "$fname-logging" );
+
# Cluster-dependent files for database and memcached
require( getRealmSpecificFilename( "$wmfConfigDir/db.php" ) );
$wgMemCachedServers = array();
diff --git a/wmf-config/logging-labs.php b/wmf-config/logging-labs.php
index ee49dd2..2667a1f 100644
--- a/wmf-config/logging-labs.php
+++ b/wmf-config/logging-labs.php
@@ -108,6 +108,9 @@
// Add logging channels defined in $wgDebugLogGroups
foreach ( $wgDebugLogGroups as $group => $dest ) {
+ if ( is_array( $dest ) ) {
+ $dest = $dest['destination'];
+ }
$wmgMonologConfig['loggers'][$group] = array(
'handlers' => array( $group, 'logstash' ),
'processors' => array( 'wiki', 'psr', 'pid', 'uid', 'web' ),
diff --git a/wmf-config/logging.php b/wmf-config/logging.php
new file mode 100644
index 0000000..4eb6986
--- /dev/null
+++ b/wmf-config/logging.php
@@ -0,0 +1,94 @@
+<?php
+if ( $wmgUseMonologLogger ) {
+ // Monolog logging configuration
+ // Note: the legacy handlers still use $wgDebugLogGroups and other
legacy
+ // logging config variables to determine logging output.
+ $wmgMonologConfig = array(
+ 'loggers' => array(
+ // Nothing is logged unless a specific channel config
is added
+ '@default' => array(
+ 'handlers' => array( 'null' ),
+ ),
+ ),
+
+ 'processors' => array(
+ 'wiki' => array(
+ 'class' => 'MWLoggerMonologProcessor',
+ ),
+ 'psr' => array(
+ 'class' =>
'\\Monolog\\Processor\\PsrLogMessageProcessor',
+ ),
+ 'pid' => array(
+ 'class' =>
'\\Monolog\\Processor\\ProcessIdProcessor',
+ ),
+ 'uid' => array(
+ 'class' => '\\Monolog\\Processor\\UidProcessor',
+ ),
+ 'web' => array(
+ 'class' => '\\Monolog\\Processor\\WebProcessor',
+ ),
+ ),
+
+ 'handlers' => array(
+ 'null' => array(
+ 'class' => '\\Monolog\\Handler\\NullHandler',
+ 'formatter' => 'line',
+ ),
+ 'logstash' => array(
+ 'class' => '\\Monolog\\Handler\\RedisHandler',
+ 'args' => array(
+ function() use ( $wmgLogstashPassword )
{
+ $servers = array(
+ '10.64.32.138', //
logstash1001.eqiad.wmnet
+ '10.64.32.137', //
logstash1002.eqiad.wmnet
+ '10.64.32.136', //
logstash1003.eqiad.wmnet
+ );
+ // Connect to a random logstash
host
+ $server = $servers[ mt_rand( 0,
count($servers) - 1 ) ];
+
+ $redis = new Redis();
+ $redis->connect( $server, 6379,
.25 );
+ $redis->auth(
$wmgLogstashPassword );
+ return $redis;
+ },
+ 'logstash'
+ ),
+ 'formatter' => 'logstash',
+ ),
+ ),
+
+ 'formatters' => array(
+ 'legacy' => array(
+ 'class' =>
'MWLoggerMonologLegacyFormatter',
+ ),
+ 'logstash' => array(
+ 'class' =>
'\\Monolog\\Formatter\\LogstashFormatter',
+ 'args' => array( 'mediawiki',
php_uname( 'n' ), null, '', 1 ),
+ ),
+ 'line' => array(
+ 'class' =>
'\\Monolog\\Formatter\\LineFormatter',
+ ),
+ ),
+ );
+
+ // Add logging channels defined in $wgDebugLogGroups
+ foreach ( $wgDebugLogGroups as $group => $dest ) {
+ if ( is_array( $dest ) ) {
+ $dest = $dest['destination'];
+ }
+ $wmgMonologConfig['loggers'][$group] = array(
+ 'handlers' => array( $group, 'logstash' ),
+ 'processors' => array( 'wiki', 'psr', 'pid', 'uid',
'web' ),
+ );
+ $wmgMonologConfig['handlers'][$group] = array(
+ 'class' => 'MWLoggerMonologHandler',
+ 'args' => array( $dest, true ),
+ 'formatter' => 'legacy',
+ );
+ }
+
+ $wgMWLoggerDefaultSpi = array(
+ 'class' => 'MWLoggerMonologSpi',
+ 'args' => array( $wmgMonologConfig ),
+ );
+}
--
To view, visit https://gerrit.wikimedia.org/r/179369
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I720f2cb5975aac40e7c1186c942d9126d67bd190
Gerrit-PatchSet: 4
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits