BryanDavis has uploaded a new change for review.

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

Change subject: Allow MWLoggerMonologHandler to take prefix from channel
......................................................................

Allow MWLoggerMonologHandler to take prefix from channel

Make MWLoggerMonologHandler replace a prefix of "{channel}" with the log
event channel when formatting an event for a udp2log stream. This allows
a simpler configuration for a typical Monolog configuration where
a separate file is desired for each logging channel that is emitted to
udp2log. One handler can be shared by multiple channels.

Change-Id: Ie2b24ba02b281b8d8cf2ad58d28874c710e1e2e5
---
M includes/debug/logger/monolog/Handler.php
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/63/198663/1

diff --git a/includes/debug/logger/monolog/Handler.php 
b/includes/debug/logger/monolog/Handler.php
index a872d84..9e7678d 100644
--- a/includes/debug/logger/monolog/Handler.php
+++ b/includes/debug/logger/monolog/Handler.php
@@ -30,7 +30,8 @@
  * - HOST: IPv4, IPv6 or hostname
  * - PORT: server port
  * - PREFIX: optional (but recommended) prefix telling udp2log how to route
- * the log event
+ * the log event. The special prefix "{channel}" will use the log event's
+ * channel as the prefix value.
  *
  * When not targeting a udp2log stream this class will act as a drop-in
  * replacement for Monolog's StreamHandler.
@@ -194,7 +195,9 @@
 
                        // Clean it up for the multiplexer
                        if ( $this->prefix !== '' ) {
-                               $text = preg_replace( '/^/m', "{$this->prefix} 
", $text );
+                               $leader = ( $this->prefix === '{channel}' ) ?
+                                       $record['channel'] : $this->prefix;
+                               $text = preg_replace( '/^/m', "{$leader} ", 
$text );
 
                                // Limit to 64KB
                                if ( strlen( $text ) > 65506 ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/198663
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2b24ba02b281b8d8cf2ad58d28874c710e1e2e5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
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