Page MenuHomePhabricator

Implement feature for logging in debug mode
Open, LowPublic

Description

I find the total lack of mw.log usage surprising. I suspect the reason may be that it takes up space/bandwidth, which - given that it is a no-op in production mode - is understandable.

Enabling logging output in PHP gives one a useful trace of the general process from initialization to handling of the request, building response, etc..

But in JavaScript there is practically no logging output in debug mode. The only output to the console is from the local log() function in mediawiki.js in case of module errors.

Perhaps we can find a way to filter them out in production mode? (Either in minification or some post-processor.)

The parser in JavaScriptMinifier seems an attractive place to implement something like this (whether or not through a hook[1]).

[1] Not an MWHook, as it's a standalone library. But this may work:

JavaScriptMinifier::addHook('comments', array( $rl, 'enableJSDebugLogging') );

ResourceLoader {
  public function enableJSDebugLogging(
    $context, // array( file =>, line => )
    $block // '/* .. \n * @log mw.log("foo", x, y) \n **/'
  ) {
  /* Replace comment with function call in debug mode. */
}
}

Details

Reference
bz37763

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 12:25 AM
bzimport set Reference to bz37763.
bzimport added a subscriber: Unknown Object (MLST).
Krinkle created this task.Jun 21 2012, 2:03 AM
Krinkle lowered the priority of this task from Normal to Low.Jan 5 2015, 3:37 PM
Krinkle updated the task description. (Show Details)
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 29 2015, 2:23 AM