The new PSR-3 debug logging system brought namespaced external code
(Psr\Log\LoggerInterface) into use in MediaWiki core. The classes I
built out to work with this system are using faux namespaces by virtue
of class names like "MWLoggerFactory", "MWLoggerLegacyLogger" and
"MWLoggerMonologSyslogHandler". Before 1.25 starts rolling out as a
tarball release I'd like to change these classes to use actual PHP
namespaces rather than this clunky collision avoidance mechanism. [0]
There is also a task to backport minimal PSR-3 support to the 1.23 LTS
system to simplify backports of code and extensions that adopt direct
use of PSR-3 and I'd like to only do that once if possible.
The color I have picked for this namespace bikeshed is
MediaWiki\Core\Logger. The MediaWiki root namespace is a pretty
obvious choice. "Core" is inserted to distinguish this fundamental
MediaWiki functionality from any existing or future extensions that
might use namespaces. I'm hoping "Logger" is sufficiently distinct
from other uses of the term "log" in MediaWiki which generally mean
"audit trail" rather than "debugging information". I'd be fine
with
throwing Debug in between Core and Logger too if consensus found for
that instead.
I'd also like to start organizing these files in a directory structure
that would be compatible with the PSR-4 auto loader standard. PSR-1
required all namespace elements to be in the file path as directories,
but PSR-4 allows a common prefix for all classes to be dropped. I was
thinking an includes/Core/ directory could be used as the common base
for these and future namespaced classes in MediaWiki core.
We had some discussion last summer [2] about namespace use in
extensions that seemed to end with "cool do it when you want" and "we
don't really need any standard conventions". Since I'm suggesting
namespace usage in core I figured this was worth another (hopefully
short) round of discussion with the larger community than is likely to
see my patches when they land in Gerrit.
[0]:
https://phabricator.wikimedia.org/T93406
[1]:
https://phabricator.wikimedia.org/T91653
[2]:
http://www.gossamer-threads.com/lists/wiki/wikitech/476296
Bryan
--
Bryan Davis Wikimedia Foundation <bd808(a)wikimedia.org>
[[m:User:BDavis_(WMF)]] Sr Software Engineer Boise, ID USA
irc: bd808 v:415.839.6885 x6855