This formatter extends LogstashFormatter to prefix records with "cee token" used for syslog and JSON structured logging. See also related task for more context. Bug: T211124 Change-Id: I3cdeb4c666f54039b5e8ecc67bd4937220333526
23 lines
600 B
PHP
23 lines
600 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Logger\Monolog;
|
|
|
|
/**
|
|
* CeeFormatter extends LogstashFormatter to prefix records with a "cee cookie".
|
|
* The cookie is used to tell JSON and non-JSON messages apart when logging to syslog.
|
|
* See also: https://www.rsyslog.com/doc/v8-stable/configuration/modules/mmjsonparse.html
|
|
*
|
|
* Compatible with Monolog 1.x only.
|
|
*
|
|
* @since 1.33
|
|
*/
|
|
class CeeFormatter extends LogstashFormatter {
|
|
/**
|
|
* Format records with a cee cookie
|
|
* @param array $record
|
|
* @return array
|
|
*/
|
|
public function format( array $record ) {
|
|
return "@cee: " . parent::format( $record );
|
|
}
|
|
}
|