Provide a backwards compatibility shim for MWLogger
authorBryan Davis <bd808@wikimedia.org>
Wed, 14 Jan 2015 01:34:36 +0000 (18:34 -0700)
committerLegoktm <legoktm.wikipedia@gmail.com>
Thu, 22 Jan 2015 22:11:08 +0000 (22:11 +0000)
MWLogger was renamed MWLoggerFactory and reduced to a static utility
class in Ie474676. Reintroduce an MWLogger that proxies the public
static methods of MWLoggerFactory to ease the transition of users who
have implemented $wgMWLoggerDefaultSpi configurations that reference
MWLogger.

As noted in the class, this is a temporary bandaid that should be ripped
off before 1.25 becomes an official release.

Change-Id: Iaccb78a510c60aab2ff20a9aa7c0869699657388

autoload.php
includes/debug/logger/Logger.php [new file with mode: 0644]

index c035439..11b5266 100644 (file)
@@ -689,6 +689,7 @@ $wgAutoloadLocalClasses = array(
        'MWFunction' => __DIR__ . '/includes/utils/MWFunction.php',
        'MWHookException' => __DIR__ . '/includes/Hooks.php',
        'MWHttpRequest' => __DIR__ . '/includes/HttpFunctions.php',
+       'MWLogger' => __DIR__ . '/includes/debug/logger/Logger.php',
        'MWLoggerFactory' => __DIR__ . '/includes/debug/logger/Factory.php',
        'MWLoggerLegacyLogger' => __DIR__ . '/includes/debug/logger/legacy/Logger.php',
        'MWLoggerLegacySpi' => __DIR__ . '/includes/debug/logger/legacy/Spi.php',
diff --git a/includes/debug/logger/Logger.php b/includes/debug/logger/Logger.php
new file mode 100644 (file)
index 0000000..27cf0cd
--- /dev/null
@@ -0,0 +1,72 @@
+<?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
+ */
+
+
+/**
+ * Backwards compatibility stub for usage from before the introduction of
+ * MWLoggerFactory.
+ *
+ * @deprecated since 1.25 Use MWLoggerFactory
+ * @todo This class should be removed before the 1.25 final release.
+ */
+class MWLogger {
+
+       /**
+        * Register a service provider to create new \Psr\Log\LoggerInterface
+        * instances.
+        *
+        * @param MWLoggerSpi $provider Provider to register
+        * @deprecated since 1.25 Use MWLoggerFactory::registerProvider()
+        */
+       public static function registerProvider( MWLoggerSpi $provider ) {
+               MWLoggerFactory::registerProvider( $provider );
+       }
+
+
+       /**
+        * Get the registered service provider.
+        *
+        * If called before any service provider has been registered, it will
+        * attempt to use the $wgMWLoggerDefaultSpi global to bootstrap
+        * MWLoggerSpi registration. $wgMWLoggerDefaultSpi is expected to be an
+        * array usable by ObjectFactory::getObjectFromSpec() to create a class.
+        *
+        * @return MWLoggerSpi
+        * @see registerProvider()
+        * @see ObjectFactory::getObjectFromSpec()
+        * @deprecated since 1.25 Use MWLoggerFactory::getProvider()
+        */
+       public static function getProvider() {
+               return MWLoggerFactory::getProvider();
+       }
+
+
+       /**
+        * Get a named logger instance from the currently configured logger factory.
+        *
+        * @param string $channel Logger channel (name)
+        * @return \Psr\Log\LoggerInterface
+        * @deprecated since 1.25 Use MWLoggerFactory::getInstance()
+        */
+       public static function getInstance( $channel ) {
+               return MWLoggerFactory::getInstance( $channel );
+       }
+
+}