BryanDavis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179369

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 wmf-config/CommonSettings-labs.php
M wmf-config/CommonSettings.php
A wmf-config/logging.php
3 files changed, 96 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/69/179369/1

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.php b/wmf-config/logging.php
new file mode 100644
index 0000000..ebd56e8
--- /dev/null
+++ b/wmf-config/logging.php
@@ -0,0 +1,91 @@
+<?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 ) {
+               $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: newchange
Gerrit-Change-Id: I720f2cb5975aac40e7c1186c942d9126d67bd190
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to