Page MenuHomePhabricator

Move MWLogger* classes to PHP namespaces rather than using faux namespaces in the class names
Closed, ResolvedPublic

Description

Class names like MWLoggerMonologSyslogHandler are a bit gross. Since most of this is hidden under the covers by the configuration system there should be very little impact to renaming the existing classes. We can leave proxy shim classes in 1.25 for those that are likely to be exposed to extensions if needed but it should be pretty easy to track down all the usage that has happened so far.

Event Timeline

bd808 raised the priority of this task from to Needs Triage.
bd808 updated the task description. (Show Details)
bd808 added a project: MediaWiki-Debug-Logger.
bd808 subscribed.

I'm thinking the namespaces should be:

  • MediaWiki\Core\Logger
  • MediaWiki\Core\Logger\Legacy
  • MediaWiki\Core\Logger\Monolog

Should the code itself move from the current location to somewhere that would be compatible with a PSR-4 autoloader like $IP/includes/Core/...?

Announced on wikitech-l to get some feedback before diving into the code change: https://lists.wikimedia.org/pipermail/wikitech-l/2015-March/081321.html

Change 198674 had a related patch set uploaded (by BryanDavis):
[WIP] Move MWLogger classes to \MediaWiki\Logger namespace

https://gerrit.wikimedia.org/r/198674

bd808 triaged this task as High priority.Apr 3 2015, 5:31 PM
bd808 added a project: MW-1.25-release.
bd808 set Security to None.
bd808 moved this task from To Do to Needs Review/Feedback on the User-bd808 board.

Change 198674 merged by jenkins-bot:
Move MWLogger classes to MediaWiki\Logger namespace

https://gerrit.wikimedia.org/r/198674

The base namespace that was used in the merged patch is MediaWiki\Logger. There is also a MediaWiki\Logger\Monolog namespace for Monolog specific classes.

The MediaWiki\Logger\LoggerFactory::getInstance( $channel ) static method is what most application level code should be interacting with to get a PSR-3 logger instance. This replaces the previous MWLoggerFactory::getInstance() and the deprecated MWLogger::getInstance() methods. Both of these are still available as shim classes until we get rid of all references to the old classes in extensions and WMF configuration files.