MediaWiki 1.40.4
ConsoleSpi.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Logger;
4
5use Psr\Log\NullLogger;
6
10class ConsoleSpi implements Spi {
11
13 private ?array $channels;
14
15 private ?Spi $forwardTo;
16
24 public function __construct( array $config = [] ) {
25 $this->channels = $config['channels'] ?? null;
26 $this->forwardTo = $config['forwardTo'] ?? null;
27 }
28
30 public function getLogger( $channel ) {
31 if ( !$this->channels || isset( $this->channels[$channel] ) ) {
32 return new ConsoleLogger( $channel, $this->channels[$channel] ?? null,
33 $this->forwardTo ? $this->forwardTo->getLogger( $channel ) : null );
34 } else {
35 return $this->forwardTo ? $this->forwardTo->getLogger( $channel ) : new NullLogger();
36 }
37 }
38}
A logger which writes to the terminal.
Simple logger SPI for logging to STDERR.
getLogger( $channel)
Get a logger instance.\Psr\Log\LoggerInterface Logger instance
__construct(array $config=[])
Service provider interface for \Psr\Log\LoggerInterface implementation libraries.
Definition Spi.php:38