logger.txt 3.6 KB

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