ResourceLoaderImage: Allow shorthand syntax
[lhc/web/wiklou.git] / docs / mwlogger.txt
1 MWLoggerFactory implements a PSR-3 [0] compatible message logging system.
2
3 Named Psr\Log\LoggerInterface instances can be obtained from the
4 MWLoggerFactory::getInstance() static method. MWLoggerFactory expects a class
5 implementing the MWLoggerSpi interface to act as a factory for new
6 Psr\Log\LoggerInterface instances.
7
8 The "Spi" in MWLoggerSpi stands for "service provider interface". A SPI is
9 an API intended to be implemented or extended by a third party. This software
10 design pattern is intended to enable framework extension and replaceable
11 components. It is specifically used in the MWLoggerFactory service to allow
12 alternate PSR-3 logging implementations to be easily integrated with
13 MediaWiki.
14
15 The MWLoggerFactory::getInstance() static method is the means by which most
16 code acquires a Psr\Log\LoggerInterface instance. This in turn delegates
17 creation of Psr\Log\LoggerInterface instances to a class implementing the
18 MWLoggerSpi service provider interface.
19
20 The service provider interface allows the backend logging library to be
21 implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the
22 classname of the default MWLoggerSpi implementation to be loaded at runtime.
23 This can either be the name of a class implementing the MWLoggerSpi with
24 a zero argument constructor or a callable that will return an MWLoggerSpi
25 instance. Alternately the MWLoggerFactory::registerProvider method can be
26 called to inject an MWLoggerSpi instance into MWLoggerFactory and bypass the
27 use of this configuration variable.
28
29 The MWLoggerLegacySpi class implements a service provider to generate
30 MWLoggerLegacyLogger instances. The MWLoggerLegacyLogger class implements the
31 PSR-3 logger interface and provides output and configuration equivalent to the
32 historic logging output of wfDebug, wfDebugLog, wfLogDBError and wfErrorLog.
33 The MWLoggerLegacySpi class is the default service provider configured in
34 DefaultSettings.php. It's usage should be transparent for users who are not
35 ready or do not wish to switch to a alternate logging platform.
36
37 The MWLoggerMonologSpi class implements a service provider to generate
38 Psr\Log\LoggerInterface instances that use the Monolog [1] logging library.
39 See the PHP docs (or source) for MWLoggerMonologSpi for details on the
40 configuration of this provider. The default configuration installs a null
41 handler that will silently discard all logging events. The documentation
42 provided by the class describes a more feature rich logging configuration.
43
44 == Classes ==
45 ; MWLoggerFactory
46 : Factory for Psr\Log\LoggerInterface loggers
47 ; MWLoggerSpi
48 : Service provider interface for MWLoggerFactory
49 ; MWLoggerNullSpi
50 : MWLoggerSpi for creating instances that discard all log events
51 ; MWLoggerLegacySpi
52 : Service provider for creating MWLoggerLegacyLogger instances
53 ; MWLoggerLegacyLogger
54 : PSR-3 logger that mimics the historical output and configuration of wfDebug,
55 wfErrorLog and other global logging functions.
56 ; MWLoggerMonologSpi
57 : MWLoggerSpi for creating instances backed by the monolog logging library
58 ; MwLoggerMonologHandler
59 : Monolog handler that replicates the udp2log and file logging
60 functionality of wfErrorLog()
61 ; MwLoggerMonologProcessor
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 MWLoggerFactory
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