MediaWiki  master
LoggerFactory.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\Logger;
22 
24 
46 
51  private static $spi;
52 
59  public static function registerProvider( Spi $provider ) {
60  self::$spi = $provider;
61  }
62 
75  public static function getProvider() {
76  if ( self::$spi === null ) {
77  global $wgMWLoggerDefaultSpi;
78  $provider = ObjectFactory::getObjectFromSpec(
79  $wgMWLoggerDefaultSpi
80  );
81  self::registerProvider( $provider );
82  }
83  return self::$spi;
84  }
85 
92  public static function getInstance( $channel ) {
93  return self::getProvider()->getLogger( $channel );
94  }
95 
99  private function __construct() {
100  // no-op
101  }
102 }
static getInstance( $channel)
Get a named logger instance from the currently configured logger factory.
static getProvider()
Get the registered service provider.
$wgMWLoggerDefaultSpi
Default service provider for creating Psr\Log\LoggerInterface instances.
Service provider interface for \Psr\Log\LoggerInterface implementation libraries. ...
Definition: Spi.php:36
static $spi
Service provider.
PSR-3 logger instance factory.
static registerProvider(Spi $provider)
Register a service provider to create new \Psr\Log\LoggerInterface instances.
__construct()
Construction of utility class is not allowed.