Page MenuHomePhabricator

Make Monolog the default debug processing layer and deprecate wfDebug* and LegacyLogger
Open, Needs TriagePublic

Description

Problem

The PSR3 logging interface has been introduced in MediaWiki to support structured logging, but no coordinated effort has been made to deprecate the use of wfDebug(), wfDebugLog(), wfLogDBError(), and wfErrorLog(). Several bugs are open in the MediaWiki-Debug-Logger project about the lack of parity between debug log usability on the Wikimedia Foundation production cluster and a typical development environment or external deployment of MediaWiki that are directly related to @bd808 taking the structured logging project to a point where it is useful for the WMF but not pushing that usability further for other MediaWiki deployments.

Who would benefit

  • MediaWiki site operators who want better insight into their operational issues
  • MediaWiki developers who don't want to think about choosing between two largely compatible but very different debug logging layers

Proposed solution

  • Replace all usage of wfDebug* in MediaWiki core with direct PSR3 usage.
  • Add Monolog as a core dependency and the default debug logging solution.
  • Make configuring Monolog easier by making helpers in the MediaWiki\Logger\Monolog namespace.
  • Remove MediaWiki\Logger\LegacyLogger from core. (It could be made a library if there are people who really love it and want to keep maintaining a homegrown debug log formatting and routing layer.)
  • Deprecate wfDebug(), wfDebugLog(), wfLogDBError(), and wfErrorLog().

See also

Event Timeline

bd808 created this task.Jan 17 2017, 9:22 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 17 2017, 9:22 PM
Tgr added a subscriber: Tgr.Jan 17 2017, 10:14 PM

It would be worth explaining how people will benefit, so that developers unfamiliar with structured logging can tell whether this is important for them.

bd808 added a comment.Jan 18 2017, 5:44 AM

It would be worth explaining how people will benefit, so that developers unfamiliar with structured logging can tell whether this is important for them.

The structured logging RfC outlines some of the perceived benefits generally:

  • Consistent mechanism to indicate log message severity (debug, info, warning, error)
  • Ability to add structured contextual data to log messages
  • Machine readable log output to enable de-duplication, alerting, reporting

From the point of view of the code base, deprecating the wfDebug* methods and replacing MediaWiki\Logger\LegacyLogger with Monolog reduces the lines of code and number of debug logging abstractions in core.

This proposal is selected for the Developer-Wishlist voting round and will be added to a MediaWiki page very soon. To the subscribers, or proposer of this task: please help modify the task description: add a brief summary (10-12 lines) of the problem that this proposal raises, topics discussed in the comments, and a proposed solution (if there is any yet). Remember to add a header with a title "Description," to your content. Please do so before February 5th, 12:00 pm UTC.