2017-04-27 23:56:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Logger;
|
|
|
|
|
|
|
|
|
|
use Psr\Log\AbstractLogger;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A logger which writes to the terminal. The output is supposed to be
|
|
|
|
|
* human-readable, and should be changed as necessary to better achieve that
|
|
|
|
|
* goal.
|
|
|
|
|
*/
|
|
|
|
|
class ConsoleLogger extends AbstractLogger {
|
2019-09-11 09:30:12 +00:00
|
|
|
/** @var string */
|
|
|
|
|
private $channel;
|
|
|
|
|
|
2019-09-08 16:59:52 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $channel
|
|
|
|
|
*/
|
2017-04-27 23:56:38 +00:00
|
|
|
public function __construct( $channel ) {
|
|
|
|
|
$this->channel = $channel;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-08 16:59:52 +00:00
|
|
|
/**
|
|
|
|
|
* @inheritDoc
|
|
|
|
|
*/
|
2017-04-27 23:56:38 +00:00
|
|
|
public function log( $level, $message, array $context = [] ) {
|
|
|
|
|
fwrite( STDERR, "[$level] " .
|
|
|
|
|
LegacyLogger::format( $this->channel, $message, $context ) );
|
|
|
|
|
}
|
|
|
|
|
}
|