aboutsummaryrefslogtreecommitdiffstats
path: root/docs/mwlogger.txt
blob: 5a3e249b3daf42ae1d2eca6129351c39a6a6782d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
MWLogger implements a PSR-3 [0] compatible message logging system.

The MWLogger class is actually a thin wrapper around any PSR-3 LoggerInterface
implementation. Named MWLogger instances can be obtained from the
MWLogger::getInstance() static method. MWLogger expects a class implementing
the MWLoggerSpi interface to act as a factory for new MWLogger instances.

The "Spi" in MWLoggerSpi stands for "service provider interface". An SPI is
a API intended to be implemented or extended by a third party. This software
design pattern is intended to enable framework extension and replaceable
components. It is specifically used in the MWLogger service to allow alternate
PSR-3 logging implementations to be easily integrated with MediaWiki.

The MWLogger::getInstance() static method is the means by which most code
acquires an MWLogger instance. This in turn delegates creation of MWLogger
instances to a class implementing the MWLoggerSpi service provider interface.

The service provider interface allows the backend logging library to be
implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the
classname of the default MWLoggerSpi implementation to be loaded at runtime.
This can either be the name of a class implementing the MWLoggerSpi with
a zero argument constructor or a callable that will return an MWLoggerSpi
instance. Alternately the MWLogger::registerProvider method can be called
to inject an MWLoggerSpi instance into MWLogger and bypass the use of this
configuration variable.

The MWLoggerMonologSpi class implements a service provider to generate
MWLogger instances that use the Monolog [1] logging library. See the PHP docs
(or source) for MWLoggerMonologSpi for details on the configuration of this
provider. The default configuration installs a null handler that will silently
discard all logging events. The documentation provided by the class describes
a more feature rich logging configuration.

== Classes ==
; MWLogger
: PSR-3 compatible logger that wraps any \Psr\Log\LoggerInterface
  implementation
; MWLoggerSpi
: Service provider interface for MWLogger factories
; MWLoggerNullSpi
: MWLoggerSpi for creating instances that discard all log events
; MWLoggerMonologSpi
: MWLoggerSpi for creating instances backed by the monolog logging library
; MwLoggerMonologHandler
: Monolog handler that replicates the udp2log and file logging
  functionality of wfErrorLog()
; MwLoggerMonologProcessor
: Monolog log processer that adds host: wfHostname() and wiki: wfWikiID()
  to all records

== Globals ==
; $wgMWLoggerDefaultSpi
: Specification for creating the default service provider interface to use
  with MWLogger

[0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
[1]: https://github.com/Seldaek/monolog