Merge "DefaultPreferencesFactory: Remove fallback for null PermissionManager"
[lhc/web/wiklou.git] / includes / debug / logger / ConsoleLogger.php
1 <?php
2
3 namespace MediaWiki\Logger;
4
5 use Psr\Log\AbstractLogger;
6
7 /**
8 * A logger which writes to the terminal. The output is supposed to be
9 * human-readable, and should be changed as necessary to better achieve that
10 * goal.
11 */
12 class ConsoleLogger extends AbstractLogger {
13 /** @var string */
14 private $channel;
15
16 /**
17 * @param string $channel
18 */
19 public function __construct( $channel ) {
20 $this->channel = $channel;
21 }
22
23 /**
24 * @inheritDoc
25 */
26 public function log( $level, $message, array $context = [] ) {
27 fwrite( STDERR, "[$level] " .
28 LegacyLogger::format( $this->channel, $message, $context ) );
29 }
30 }