Page MenuHomePhabricator

It is difficult to determine in which log bucket a logging call will end up
Closed, ResolvedPublic


Suppose I want to debug memcached usage in MediaWiki. I look at MemcachedPeclBagOStuff.php and see that it is calling $this->debugLog() with what looks like useful debugging data. I want to get that data. How do I know where it is going and how to configure it? Previously, the log channel was right there. Now I have to hunt down the constructor, which isn't always easy. Grepping for 'new MemcachedPeclBagOStuff' won't find it.

@bd808 suggests that we simply "ditch our weird habit of arbitrary log channel names and instead make them all match the class name except for 'exceptional' log channels". I think it's a great idea.

Event Timeline

The way I did this in a previous framework was to have the loggers built automagically based on get_class( $this ) and some post-processing that turned the PECL style classnames (Foo_Bar_Baz) used in that framework into slightly prettier names ( That stack was backed by a hierarchical logging framework so using the dotted names allowed configuration of the 'foo' channel to apply to anything that inherited from it. That setup made things like configuring all the log channels like project.db.* in one place easy.

Monolog doesn't have built in support for hierarchies of loggers. I built a Logger class long ago that worked around this, but it has never been tested in a large project.

Changing all the log channel names will be disruptive to anyone who has built a fancy logging setup (e.g. WMF prod), so it probably shouldn't happen until we start the v1.28 dev cycle.

Or just ensure channels are always prefixed by extension or component (/includes subdirectory) names and make it easy to iterate all channels with a given prefix.

Krinkle claimed this task.
Krinkle moved this task from Untriaged to libs/objectcache on the MediaWiki-Cache board.
Krinkle added a subscriber: Krinkle.

The BagOStuff structure has always supported configuring the log channel via the loggroup key in $wgObjectCaches. However, MemcachedPeclBagOStuff previously bypassed this.

As part of the conversion to PSR-3 LoggerAwareInterface, this was fixed. It now uses $this->logger for debug logs as well. The Logger object is injected by service wiring and defaults to objectcache. The memcached presets in DefaultSettings.php default to memcached.