From: Tim Starling Date: Wed, 24 Sep 2008 08:17:35 +0000 (+0000) Subject: * Add a simple log demultiplexer, written in python, for low-volume MediaWiki logs X-Git-Tag: 1.31.0-rc.0~45120 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=aab518cf7875270c36aefadaa5b7ad58085a0933;p=lhc%2Fweb%2Fwiklou.git * Add a simple log demultiplexer, written in python, for low-volume MediaWiki logs * in wfErrorLog(): clean up log text so that it works properly with the multiplexer --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 80e5843776..440791eeaf 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -297,24 +297,28 @@ function wfErrorLog( $text, $file ) { $protocol = $m[1]; $host = $m[2]; $port = $m[3]; - $prefix = isset( $m[4] ) ? $m[4] : ''; + $prefix = isset( $m[4] ) ? $m[4] : false; } elseif ( preg_match( '!^(tcp|udp):(?://)?([a-zA-Z0-9-]+):(\d+)(?:/(.*))?$!', $file, $m ) ) { $protocol = $m[1]; $host = $m[2]; $port = $m[3]; - $prefix = isset( $m[4] ) ? $m[4] : ''; + $prefix = isset( $m[4] ) ? $m[4] : false; } else { throw new MWException( __METHOD__.": Invalid UDP specification" ); } - $prefix = strval( $prefix ); - if ( $prefix != '' ) { - $prefix .= ' '; + // Clean it up for the multiplexer + if ( strval( $prefix ) !== '' ) { + $text = preg_replace( '/^/m', $prefix . ' ', $text ); + if ( substr( $text, -1 ) != "\n" ) { + $text .= "\n"; + } } + $sock = fsockopen( "$protocol://$host", $port ); if ( !$sock ) { return; } - fwrite( $sock, $prefix . $text ); + fwrite( $sock, $text ); fclose( $sock ); } else { wfSuppressWarnings();