Time wounds all heels. During the code review for the PSR-3 logging introduction, several people asked me why we needed a wrapper for Psr\Log\LoggerInterface if the point was to use the standard. At the time I was convinced that it would be better to introduce the dependency via a wrapper class so that we could use the wrapper to patch over any deficiencies that we might find in the PSR-3 API. After going on to work on a project to disentangle other MediaWiki components from internal project dependencies I have suddenly and clearly seen the error of my ways. We still need a logger factory as PSR-3 does not specify a standard mechanism for creating Psr\Log\LoggerInterface instances. My solution is to convert MWLogger into MWLoggerFactory to retain a static factory interface for creating PSR-3 loggers but remove the MWLogger wrapper class itself in favor of direct exposure of Psr\Log\LoggerInterface to the MediaWiki consumer classes. Change-Id: Ie47467657dcf341991ada00827dca5e8eff95438
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
*
|
|
* @file
|
|
*/
|
|
|
|
/**
|
|
* Service provider interface for \Psr\Log\LoggerInterface implementation
|
|
* libraries.
|
|
*
|
|
* MediaWiki can be configured to use a class implementing this interface to
|
|
* create new \Psr\Log\LoggerInterface instances via either the
|
|
* $wgMWLoggerDefaultSpi global variable or code that constructs an instance
|
|
* and registers it via the MWLoggerFactory::registerProvider() static method.
|
|
*
|
|
* @see MWLoggerFactory
|
|
* @since 1.25
|
|
* @author Bryan Davis <bd808@wikimedia.org>
|
|
* @copyright © 2014 Bryan Davis and Wikimedia Foundation.
|
|
*/
|
|
interface MWLoggerSpi {
|
|
|
|
/**
|
|
* Get a logger instance.
|
|
*
|
|
* @param string $channel Logging channel
|
|
* @return \Psr\Log\LoggerInterface Logger instance
|
|
*/
|
|
public function getLogger( $channel );
|
|
|
|
}
|