Move logging-related code to its own directory

Also make sure class and file names have the same case.

Change-Id: I21042e40030051326f8c55fd62a86a54e9011a4a
This commit is contained in:
Gergő Tisza 2014-09-04 23:00:55 +00:00
parent 91b7bd265a
commit c4c262bf44
14 changed files with 80 additions and 77 deletions

View file

@ -113,7 +113,7 @@ $wgResourceModules += array(
'dependencies' => array(
'mmv.base',
'mmv.ActionLogger',
'mmv.logging.ActionLogger',
'mmv.ui',
'mmv.ui.canvas',
'mmv.ui.canvasButtons',
@ -288,7 +288,7 @@ $wgResourceModules += array(
'mmv.model.Repo',
'mmv.model.Thumbnail',
'mmv.model.User',
'mmv.performance',
'mmv.logging.Performance',
'oojs',
),
),
@ -444,7 +444,7 @@ $wgResourceModules += array(
'dependencies' => array(
'jquery.color',
'mediawiki.jqueryMsg',
'mmv.ActionLogger',
'mmv.logging.ActionLogger',
'mmv.ui',
'mmv.HtmlUtils',
'oojs',
@ -496,7 +496,7 @@ $wgResourceModules += array(
'dependencies' => array(
'mediawiki.user',
'mmv.HtmlUtils',
'mmv.ActionLogger',
'mmv.logging.ActionLogger',
'mmv.ui',
'mmv.ui.progressBar',
'mmv.ui.stripeButtons',
@ -750,9 +750,9 @@ $wgResourceModules += array(
),
),
'mmv.logger' => $wgMediaViewerResourceTemplate + array(
'mmv.logging.Logger' => $wgMediaViewerResourceTemplate + array(
'scripts' => array(
'mmv/mmv.Logger.js',
'mmv/logging/mmv.logging.Logger.js',
),
'dependencies' => array(
@ -760,26 +760,27 @@ $wgResourceModules += array(
),
),
'mmv.performance' => $wgMediaViewerResourceTemplate + array(
'mmv.logging.Performance' => $wgMediaViewerResourceTemplate + array(
'scripts' => array(
'mmv/mmv.performance.js',
'mmv/logging/mmv.logging.Performance.js',
),
'dependencies' => array(
'mmv.base',
'mmv.logger',
'mmv.logging.Logger',
'oojs',
),
),
'mmv.api' => $wgMediaViewerResourceTemplate + array(
'mmv.logging.Api' => $wgMediaViewerResourceTemplate + array(
'scripts' => array(
'mmv/mmv.api.js',
'mmv/logging/mmv.logging.Api.js',
),
'dependencies' => array(
'mediawiki.api',
'mmv.base',
'mmv.logging.Logger',
'oojs',
),
),
@ -806,15 +807,15 @@ $wgResourceModules += array(
),
'dependencies' => array(
'mmv.api',
'mmv.logging.Api',
'mmv.base',
'mmv.lightboximage',
'mmv.ActionLogger',
'mmv.logging.ActionLogger',
'mmv.model.TaskQueue',
'mmv.lightboxinterface',
'mmv.provider',
'mmv.routing',
'mmv.DurationLogger',
'mmv.logging.DurationLogger',
'jquery.fullscreen',
'jquery.hidpi',
'jquery.scrollTo',
@ -844,9 +845,9 @@ $wgResourceModules += array(
'jquery.hashchange',
'mediawiki.Title',
'mmv.Config',
'mmv.ActionLogger',
'mmv.logging.ActionLogger',
'mmv.HtmlUtils',
'mmv.DurationLogger',
'mmv.logging.DurationLogger',
'jquery.scrollTo',
),
@ -866,26 +867,26 @@ $wgResourceModules += array(
),
),
'mmv.ActionLogger' => $wgMediaViewerResourceTemplate + array(
'mmv.logging.ActionLogger' => $wgMediaViewerResourceTemplate + array(
'scripts' => array(
'mmv/mmv.ActionLogger.js',
'mmv/logging/mmv.logging.ActionLogger.js',
),
'dependencies' => array(
'mmv.base',
'mmv.logger',
'mmv.logging.Logger',
'oojs'
)
),
'mmv.DurationLogger' => $wgMediaViewerResourceTemplate + array(
'mmv.logging.DurationLogger' => $wgMediaViewerResourceTemplate + array(
'scripts' => array(
'mmv/mmv.DurationLogger.js',
'mmv/logging/mmv.logging.DurationLogger.js',
),
'dependencies' => array(
'mmv.base',
'mmv.logger',
'mmv.logging.Logger',
'oojs',
'mediawiki.user',
)
@ -925,9 +926,9 @@ $wgExtensionFunctions[] = function () {
$wgEventLoggingSchemas[ 'MultimediaViewerNetworkPerformance' ] = 7917896;
$wgEventLoggingSchemas[ 'MultimediaViewerDuration' ] = 8572641;
$wgResourceModules['mmv.ActionLogger']['dependencies'][] = 'ext.eventLogging';
$wgResourceModules['mmv.performance']['dependencies'][] = 'ext.eventLogging';
$wgResourceModules['mmv.DurationLogger']['dependencies'][] = 'ext.eventLogging';
$wgResourceModules['mmv.logging.ActionLogger']['dependencies'][] = 'ext.eventLogging';
$wgResourceModules['mmv.logging.Performance']['dependencies'][] = 'ext.eventLogging';
$wgResourceModules['mmv.logging.DurationLogger']['dependencies'][] = 'ext.eventLogging';
}
};

View file

@ -183,15 +183,15 @@ class MultimediaViewerHooks {
'scripts' => array(
'tests/qunit/mmv/mmv.bootstrap.test.js',
'tests/qunit/mmv/mmv.test.js',
'tests/qunit/mmv/mmv.DurationLogger.test.js',
'tests/qunit/mmv/mmv.lightboxinterface.test.js',
'tests/qunit/mmv/mmv.lightboximage.test.js',
'tests/qunit/mmv/mmv.ThumbnailWidthCalculator.test.js',
'tests/qunit/mmv/mmv.EmbedFileFormatter.test.js',
'tests/qunit/mmv/mmv.Config.test.js',
'tests/qunit/mmv/mmv.HtmlUtils.test.js',
'tests/qunit/mmv/mmv.performance.test.js',
'tests/qunit/mmv/mmv.ActionLogger.test.js',
'tests/qunit/mmv/logging/mmv.logging.DurationLogger.test.js',
'tests/qunit/mmv/logging/mmv.logging.Performance.test.js',
'tests/qunit/mmv/logging/mmv.logging.ActionLogger.test.js',
'tests/qunit/mmv/model/mmv.model.test.js',
'tests/qunit/mmv/model/mmv.model.IwTitle.test.js',
'tests/qunit/mmv/model/mmv.model.TaskQueue.test.js',

View file

@ -5,21 +5,22 @@
{
"name": "Base",
"classes": [
"mw.mmv.Api",
"mw.mmv.ActionLogger",
"mw.mmv.Config",
"mw.mmv.DurationLogger",
"mw.mmv.EmbedFileFormatter",
"mw.mmv.HtmlUtils",
"mw.mmv.LightboxImage",
"mw.mmv.LightboxInterface",
"mw.mmv.Logger",
"mw.mmv.MultimediaViewer",
"mw.mmv.MultimediaViewerBootstrap",
"mw.mmv.Performance",
"mw.mmv.ThumbnailWidthCalculator"
]
},
{
"name": "Loggers",
"classes": [
"mw.mmv.logging.*"
]
},
{
"name": "Models",
"classes": [

View file

@ -20,13 +20,13 @@
/**
* Writes log entries
* @class mw.mmv.ActionLogger
* @extends mw.mmv.Logger
* @class mw.mmv.logging.ActionLogger
* @extends mw.mmv.logging.Logger
* @constructor
*/
function ActionLogger() {}
oo.inheritClass( ActionLogger, mw.mmv.Logger );
oo.inheritClass( ActionLogger, mw.mmv.logging.Logger );
L = ActionLogger.prototype;
@ -138,6 +138,6 @@
return Math.floor( Math.random() * factor ) === 0;
};
mw.mmv.ActionLogger = ActionLogger;
mw.mmv.actionLogger = new mw.mmv.ActionLogger();
mw.mmv.logging.ActionLogger = ActionLogger;
mw.mmv.actionLogger = new ActionLogger();
}( mediaWiki, jQuery, OO ) );

View file

@ -17,8 +17,8 @@
( function ( mw, $, oo ) {
/**
* Runs performance analysis on requests via mw.mmv.Performance
* @class mw.mmv.Api
* Runs performance analysis on requests via mw.mmv.logging.Performance
* @class mw.mmv.logging.Api
* @extends mw.Api
* @constructor
* @param {string} type The type of the requests to be made through this API.
@ -27,8 +27,8 @@
function Api( type, options ) {
mw.Api.call( this, options );
/** @property {mw.mmv.Performance} performance Used to record performance data. */
this.performance = new mw.mmv.Performance();
/** @property {mw.mmv.logging.Performance} performance Used to record performance data. */
this.performance = new mw.mmv.logging.Performance();
/** @property {string} type Type of requests being sent via this API. */
this.type = type;
@ -52,5 +52,5 @@
} );
};
mw.mmv.Api = Api;
mw.mmv.logging.Api = Api;
}( mediaWiki, jQuery, OO ) );

View file

@ -20,15 +20,15 @@
/**
* Writes EventLogging entries for duration measurements
* @class mw.mmv.DurationLogger
* @extends mw.mmv.Logger
* @class mw.mmv.logging.DurationLogger
* @extends mw.mmv.logging.Logger
* @constructor
*/
function DurationLogger() {
this.starts = {};
}
oo.inheritClass( DurationLogger, mw.mmv.Logger );
oo.inheritClass( DurationLogger, mw.mmv.logging.Logger );
L = DurationLogger.prototype;

View file

@ -20,7 +20,7 @@
/**
* Abstract class providing common code for EventLogging loggers
* @class mw.mmv.Logger
* @class mw.mmv.logging.Logger
* @abstract
*/
function Logger() {
@ -124,5 +124,6 @@
}
};
mw.mmv.Logger = Logger;
mw.mmv.logging = {};
mw.mmv.logging.Logger = Logger;
}( mediaWiki, jQuery ) );

View file

@ -21,13 +21,13 @@
/**
* Measures the network performance
* See <https://meta.wikimedia.org/wiki/Schema:MultimediaViewerNetworkPerformance>
* @class mw.mmv.Performance
* @extends mw.mmv.Logger
* @class mw.mmv.logging.Performance
* @extends mw.mmv.logging.Logger
* @constructor
*/
function Performance() {}
oo.inheritClass( Performance, mw.mmv.Logger );
oo.inheritClass( Performance, mw.mmv.logging.Logger );
P = Performance.prototype;
@ -404,6 +404,6 @@
new Performance().init();
mw.mmv.Performance = Performance;
mw.mmv.logging.Performance = Performance;
}( mediaWiki, jQuery, OO ) );

View file

@ -44,7 +44,7 @@
// We wait for document readiness because mw.loader.using writes to the DOM
// which can cause a blank page if it happens before DOM readiness
$document.ready( function () {
mw.loader.using( [ 'mmv.bootstrap.autostart', 'mmv.DurationLogger' ] , function() {
mw.loader.using( [ 'mmv.bootstrap.autostart', 'mmv.logging.DurationLogger' ] , function() {
mw.mmv.bootstrap.whenThumbsReady().then( function () {
mw.mmv.durationLogger.stop( 'early-click-to-replay-click', start );

View file

@ -38,7 +38,7 @@
* @property {mw.mmv.provider.ImageInfo}
* @private
*/
this.imageInfoProvider = new mw.mmv.provider.ImageInfo( new mw.mmv.Api( 'imageinfo' ),
this.imageInfoProvider = new mw.mmv.provider.ImageInfo( new mw.mmv.logging.Api( 'imageinfo' ),
// Short-circuit, don't fallback, to save some tiny amount of time
{ language: mw.config.get( 'wgUserLanguage', false ) || mw.config.get( 'wgContentLanguage', 'en' ) }
);
@ -47,14 +47,14 @@
* @property {mw.mmv.provider.FileRepoInfo}
* @private
*/
this.fileRepoInfoProvider = new mw.mmv.provider.FileRepoInfo( new mw.mmv.Api( 'filerepoinfo' ),
this.fileRepoInfoProvider = new mw.mmv.provider.FileRepoInfo( new mw.mmv.logging.Api( 'filerepoinfo' ),
{ maxage: apiCacheMaxAge } );
/**
* @property {mw.mmv.provider.ThumbnailInfo}
* @private
*/
this.thumbnailInfoProvider = new mw.mmv.provider.ThumbnailInfo( new mw.mmv.Api( 'thumbnailinfo' ),
this.thumbnailInfoProvider = new mw.mmv.provider.ThumbnailInfo( new mw.mmv.logging.Api( 'thumbnailinfo' ),
{ maxage: apiCacheMaxAge } );
/**
@ -67,7 +67,7 @@
* @property {mw.mmv.provider.UserInfo}
* @private
*/
this.userInfoProvider = new mw.mmv.provider.UserInfo( new mw.mmv.Api( 'userinfo' ), {
this.userInfoProvider = new mw.mmv.provider.UserInfo( new mw.mmv.logging.Api( 'userinfo' ), {
useApi: this.needGender(),
maxage: apiCacheMaxAge
} );
@ -76,21 +76,21 @@
* @property {mw.mmv.provider.ImageUsage}
* @private
*/
this.imageUsageProvider = new mw.mmv.provider.ImageUsage( new mw.mmv.Api( 'imageusage' ),
this.imageUsageProvider = new mw.mmv.provider.ImageUsage( new mw.mmv.logging.Api( 'imageusage' ),
{ maxage: apiCacheMaxAge } );
/**
* @property {mw.mmv.provider.GlobalUsage}
* @private
*/
this.globalUsageProvider = new mw.mmv.provider.GlobalUsage( new mw.mmv.Api( 'globalusage' ), {
this.globalUsageProvider = new mw.mmv.provider.GlobalUsage( new mw.mmv.logging.Api( 'globalusage' ), {
useApi: mw.config.get( 'wgMultimediaViewer' ).globalUsageAvailable,
maxage: apiCacheMaxAge
} );
// replace with this one to test global usage on a local wiki without going through all the
// hassle required for installing the extension:
//this.globalUsageProvider = new mw.mmv.provider.GlobalUsage(
// new mw.mmv.Api( 'globalusage', { ajax: { url: 'http://commons.wikimedia.org/w/api.php', dataType: 'jsonp' } } )
// new mw.mmv.logging.Api( 'globalusage', { ajax: { url: 'http://commons.wikimedia.org/w/api.php', dataType: 'jsonp' } } )
//);
/**

View file

@ -23,10 +23,10 @@
*/
function Image() {
/**
* @property {mw.mmv.Performance}
* @property {mw.mmv.logging.Performance}
* @private
*/
this.performance = new mw.mmv.Performance();
this.performance = new mw.mmv.logging.Performance();
/**
* AJAX call cache.
@ -37,7 +37,7 @@
}
/**
* Loads an image and returns it. Includes performance metrics via mw.mmv.Performance.
* Loads an image and returns it. Includes performance metrics via mw.mmv.logging.Performance.
* When the browser supports it, the image is loaded as an AJAX request.
* @param {string} url
* @return {jQuery.Promise.<HTMLImageElement>} A promise which resolves to the image object.

View file

@ -1,9 +1,9 @@
( function ( mw, $ ) {
QUnit.module( 'mmv.ActionLogger', QUnit.newMwEnvironment() );
QUnit.module( 'mmv.logging.ActionLogger', QUnit.newMwEnvironment() );
QUnit.test( 'log()', 8, function ( assert ) {
var fakeEventLog = { logEvent : this.sandbox.stub() },
logger = new mw.mmv.ActionLogger(),
logger = new mw.mmv.logging.ActionLogger(),
action1key = 'test-1',
action1value = 'Test',
action2key = 'test-2',

View file

@ -1,5 +1,5 @@
( function ( mw, $ ) {
QUnit.module( 'mmv.DurationLogger', QUnit.newMwEnvironment({
QUnit.module( 'mmv.logging.DurationLogger', QUnit.newMwEnvironment({
setup: function () {
this.clock = this.sandbox.useFakeTimers();
}

View file

@ -16,7 +16,7 @@
*/
( function ( mw, $ ) {
QUnit.module( 'mmv.performance', QUnit.newMwEnvironment() );
QUnit.module( 'mmv.logging.Performance', QUnit.newMwEnvironment() );
function createFakeXHR( response ) {
return {
@ -37,7 +37,7 @@
}
QUnit.test( 'recordEntry: basic', 7, function ( assert ) {
var performance = new mw.mmv.Performance(),
var performance = new mw.mmv.logging.Performance(),
fakeEventLog = { logEvent : this.sandbox.stub() },
type = 'gender',
total = 100;
@ -110,7 +110,7 @@
},
country = 'FR',
type = 'image',
performance = new mw.mmv.Performance(),
performance = new mw.mmv.logging.Performance(),
status = 200,
metered = true,
bandwidth = 45.67,
@ -190,7 +190,7 @@
varnish2 = 'cp3006',
varnish3 = 'cp3005',
testString = varnish1 + ' miss (0), ' + varnish2 + ' miss (0), ' + varnish3 + ' frontend hit (1)',
performance = new mw.mmv.Performance(),
performance = new mw.mmv.logging.Performance(),
varnishXCache = performance.parseVarnishXCacheHeader( testString );
assert.strictEqual( varnishXCache.varnish1, varnish1, 'First varnish server name extracted' );
@ -220,7 +220,7 @@
var type = 'foo',
url = 'http://example.com/',
response = {},
performance = new mw.mmv.Performance();
performance = new mw.mmv.logging.Performance();
performance.newXHR = function () { return createFakeXHR( response ); };
@ -242,7 +242,7 @@
QUnit.asyncTest( 'record() with old browser', 1, function ( assert ) {
var type = 'foo',
url = 'http://example.com/',
performance = new mw.mmv.Performance();
performance = new mw.mmv.logging.Performance();
performance.newXHR = function () { throw 'XMLHttpRequest? What\'s that?'; };
@ -252,9 +252,9 @@
} );
} );
QUnit.test( 'mw.mmv.Api', 3, function ( assert ) {
QUnit.test( 'mw.mmv.logging.Api', 3, function ( assert ) {
var api,
oldRecord = mw.mmv.Performance.prototype.recordJQueryEntryDelayed,
oldRecord = mw.mmv.logging.Performance.prototype.recordJQueryEntryDelayed,
oldAjax = mw.Api.prototype.ajax,
ajaxCalled = false,
fakeJqxhr = {};
@ -264,18 +264,18 @@
return $.Deferred().resolve( {}, fakeJqxhr );
};
mw.mmv.Performance.prototype.recordJQueryEntryDelayed = function ( type, total, jqxhr ) {
mw.mmv.logging.Performance.prototype.recordJQueryEntryDelayed = function ( type, total, jqxhr ) {
assert.strictEqual( type, 'foo', 'type was passed correctly' );
assert.strictEqual( jqxhr, fakeJqxhr, 'jqXHR was passed correctly' );
};
api = new mw.mmv.Api( 'foo' );
api = new mw.mmv.logging.Api( 'foo' );
api.ajax();
assert.ok( ajaxCalled, 'parent ajax() function was called' );
mw.mmv.Performance.prototype.recordJQueryEntryDelayed = oldRecord;
mw.mmv.logging.Performance.prototype.recordJQueryEntryDelayed = oldRecord;
mw.Api.prototype.ajax = oldAjax;
} );
}( mediaWiki, jQuery ) );