MediaWiki master
ConsoleSpi.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Logger;
4
5use Psr\Log\NullLogger;
6
16class ConsoleSpi implements Spi {
17
19 private ?array $channels;
20
21 private ?Spi $forwardTo;
22
30 public function __construct( array $config = [] ) {
31 $this->channels = $config['channels'] ?? null;
32 $this->forwardTo = $config['forwardTo'] ?? null;
33 }
34
36 public function getLogger( $channel ) {
37 if ( !$this->channels || isset( $this->channels[$channel] ) ) {
38 return new ConsoleLogger( $channel, $this->channels[$channel] ?? null,
39 $this->forwardTo ? $this->forwardTo->getLogger( $channel ) : null );
40 } else {
41 return $this->forwardTo ? $this->forwardTo->getLogger( $channel ) : new NullLogger();
42 }
43 }
44}
Write logs to command-line output (STDERR).
ConsoleLogger service provider for MediaWiki\Logger\LoggerFactory.
getLogger( $channel)
Get a logger instance.\Psr\Log\LoggerInterface Logger instance
__construct(array $config=[])
Service provider interface to create \Psr\Log\LoggerInterface objects.
Definition Spi.php:64