| 1 | <?php |
| 2 | /** |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along |
| 14 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 | * http://www.gnu.org/copyleft/gpl.html |
| 17 | * |
| 18 | * @file |
| 19 | */ |
| 20 | |
| 21 | namespace MediaWiki\Logger; |
| 22 | |
| 23 | /** |
| 24 | * @defgroup Debug Debug logging |
| 25 | * |
| 26 | * To primary APIs for this feature, and the classes where their documentation |
| 27 | * starts, are: |
| 28 | * |
| 29 | * - MediaWiki\Logger\LoggerFactory, this creates all logger objects at |
| 30 | * run time. |
| 31 | * |
| 32 | * - MediaWiki\Logger\Spi, to develop or configure the service classes |
| 33 | * that internally create logger objects. For example, MediaWiki\Logger\LegacyLogger |
| 34 | * is the default Spi that backs features like $wgDebugLogFile. |
| 35 | * MediaWiki\Logger\MonologSpi is an Spi you can opt-in to via $wgMWLoggerDefaultSpi |
| 36 | * to enable structured logging with destinations like Syslog and Logstash, |
| 37 | * and "processor" and "formatter" features to augment messages with metadata, |
| 38 | * as powered by the Monolog library. |
| 39 | * |
| 40 | * - MWDebug, the logic behind $wgDebugToolbar. |
| 41 | * |
| 42 | * @see [Logger documentation](@ref debuglogger) in docs/Logger.md |
| 43 | */ |
| 44 | |
| 45 | /** |
| 46 | * Service provider interface to create \Psr\Log\LoggerInterface objects. |
| 47 | * |
| 48 | * MediaWiki can be configured to use a class implementing this interface |
| 49 | * via the $wgMWLoggerDefaultSpi configuration variable. |
| 50 | * |
| 51 | * This configuration is consumed by MediaWiki\Logger\LoggerFactory, which is |
| 52 | * where we create logger objects. |
| 53 | * |
| 54 | * While not recommended in production code, you can construct and install |
| 55 | * an Spi class at runtime via MediaWiki\Logger\LoggerFactory::registerProvider |
| 56 | * (e.g. to power debug features in PHPUnit bootstrapping, or Maintenance |
| 57 | * scripts). |
| 58 | * |
| 59 | * @stable to implement |
| 60 | * @since 1.25 |
| 61 | * @ingroup Debug |
| 62 | * @copyright © 2014 Wikimedia Foundation and contributors |
| 63 | */ |
| 64 | interface Spi { |
| 65 | |
| 66 | /** |
| 67 | * Get a logger instance. |
| 68 | * |
| 69 | * @param string $channel Logging channel |
| 70 | * @return \Psr\Log\LoggerInterface Logger instance |
| 71 | */ |
| 72 | public function getLogger( $channel ); |
| 73 | |
| 74 | } |