Merge "Added option to specify "Various authors" as author in extension credits using...
[lhc/web/wiklou.git] / docs / logger.txt
1 MediaWiki\Logger\LoggerFactory implements a PSR-3 [0] compatible message
2 logging system.
3
4 Named Psr\Log\LoggerInterface instances can be obtained from the
5 MediaWiki\Logger\LoggerFactory::getInstance() static method.
6 MediaWiki\Logger\LoggerFactory expects a class implementing the
7 MediaWiki\Logger\Spi interface to act as a factory for new
8 Psr\Log\LoggerInterface instances.
9
10 The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An
11 SPI is an API intended to be implemented or extended by a third party. This
12 software design pattern is intended to enable framework extension and
13 replaceable components. It is specifically used in the
14 MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging
15 implementations to be easily integrated with MediaWiki.
16
17 The service provider interface allows the backend logging library to be
18 implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the
19 classname of the default MediaWiki\Logger\Spi implementation to be loaded at
20 runtime. This can either be the name of a class implementing the
21 MediaWiki\Logger\Spi with a zero argument constructor or a callable that will
22 return an MediaWiki\Logger\Spi instance. Alternately the
23 MediaWiki\Logger\LoggerFactory::registerProvider() static method can be called
24 to inject an MediaWiki\Logger\Spi instance into the LoggerFactory and bypass
25 the use of the default configuration variable.
26
27 The MediaWiki\Logger\LegacySpi class implements a service provider to generate
28 MediaWiki\Logger\LegacyLogger instances. The MediaWiki\Logger\LegacyLogger
29 class implements the PSR-3 logger interface and provides output and
30 configuration equivalent to the historic logging output of wfDebug,
31 wfDebugLog, wfLogDBError and wfErrorLog. The MediaWiki\Logger\LegacySpi class
32 is the default service provider configured in DefaultSettings.php. It's usage
33 should be transparent for users who are not ready or do not wish to switch to
34 a alternate logging platform.
35
36 The MediaWiki\Logger\MonologSpi class implements a service provider to
37 generate Psr\Log\LoggerInterface instances that use the Monolog [1] logging
38 library. See the PHP docs (or source) for MediaWiki\Logger\MonologSpi for
39 details on the configuration of this provider. The default configuration
40 installs a null handler that will silently discard all logging events. The
41 documentation provided by the class describes a more feature rich logging
42 configuration.
43
44 == Classes ==
45 ; MediaWiki\Logger\LoggerFactory
46 : Factory for Psr\Log\LoggerInterface loggers
47 ; MediaWiki\Logger\Spi
48 : Service provider interface for MediaWiki\Logger\LoggerFactory
49 ; MediaWiki\Logger\NullSpi
50 : MediaWiki\Logger\Spi for creating instances that discard all log events
51 ; MediaWiki\Logger\LegacySpi
52 : Service provider for creating MediaWiki\Logger\LegacyLogger instances
53 ; MediaWiki\Logger\LegacyLogger
54 : PSR-3 logger that mimics the historical output and configuration of wfDebug,
55 wfErrorLog and other global logging functions.
56 ; MediaWiki\Logger\MonologSpi
57 : MediaWiki\Logger\Spi for creating instances backed by the monolog logging library
58 ; MediaWiki\Logger\Monolog\LegacyHandler
59 : Monolog handler that replicates the udp2log and file logging
60 functionality of wfErrorLog()
61 ; MediaWiki\Logger\Monolog\WikiProcessor
62 : Monolog log processer that adds host: wfHostname() and wiki: wfWikiID()
63 to all records
64
65 == Globals ==
66 ; $wgMWLoggerDefaultSpi
67 : Specification for creating the default service provider interface to use
68 with MediaWiki\Logger\LoggerFactory
69
70 [0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
71 [1]: https://github.com/Seldaek/monolog