MarkTraceur has uploaded a new change for review.

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


Change subject: No need to use custom mw.log anymore
......................................................................

No need to use custom mw.log anymore

Transform some of the mw.log calls and delete the weird custom library
that has been there for a while.

Change-Id: Ieb7121fa85ce36655749625c0d5447844c3387a0
---
M UploadWizardHooks.php
M UploadWizardPage.js
M resources/mw.DestinationChecker.js
M resources/mw.FirefoggTransport.js
M resources/mw.FormDataTransport.js
M resources/mw.IframeTransport.js
D resources/mw.Log.js
M resources/mw.UploadWizardLicenseInput.js
M resources/mw.UploadWizardUpload.js
9 files changed, 17 insertions(+), 154 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/17/79917/1

diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 83e4b65..859c875 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -53,7 +53,6 @@
                                'resources/mw.fileApi.js',
                                'resources/mw.units.js',
                                'resources/mw.canvas.js',
-                               'resources/mw.Log.js',
                                'resources/mw.UtilitiesTime.js',
                                'resources/mw.ErrorDialog.js',
                                'resources/mw.ConfirmCloseWindow.js',
diff --git a/UploadWizardPage.js b/UploadWizardPage.js
index 85d51a1..24053a9 100644
--- a/UploadWizardPage.js
+++ b/UploadWizardPage.js
@@ -12,9 +12,6 @@
 mw.UploadWizardPage = function () {
 
        var config = mw.config.get( 'UploadWizardConfig' );
-       if ( !config.debug ) {
-               mw.log.level = mw.log.NONE;
-       }
 
        var uploadWizard = new mw.UploadWizard( config );
        uploadWizard.createInterface( '#upload-wizard' );
diff --git a/resources/mw.DestinationChecker.js 
b/resources/mw.DestinationChecker.js
index 310e8f8..05995f8 100644
--- a/resources/mw.DestinationChecker.js
+++ b/resources/mw.DestinationChecker.js
@@ -225,7 +225,7 @@
 
                        if ( !data || !data.query || !data.query.pages ) {
                                // Ignore a null result
-                               mw.log("mw.DestinationChecker::checkUnique> No 
data in checkUnique result", 'debug');
+                               mw.log("mw.DestinationChecker::checkUnique> No 
data in checkUnique result");
                                return;
                        }
 
@@ -292,7 +292,7 @@
 
                var err = function( code, result ) {
                        _this.spinner( false );
-                       mw.log("mw.DestinationChecker::checkUnique> error in 
checkUnique result: " + code, 'debug');
+                       mw.log("mw.DestinationChecker::checkUnique> error in 
checkUnique result: " + code);
                        return;
                };
 
diff --git a/resources/mw.FirefoggTransport.js 
b/resources/mw.FirefoggTransport.js
index 428e3e1..755f4bb 100644
--- a/resources/mw.FirefoggTransport.js
+++ b/resources/mw.FirefoggTransport.js
@@ -114,13 +114,13 @@
         */
        getSourceFileInfo: function() {
                if ( !this.fogg.sourceInfo ) {
-                       mw.log( 'Error:: No firefogg source info is available' 
);
+                       mw.log.warn( 'Error:: No firefogg source info is 
available' );
                        return false;
                }
                try {
                        this.sourceFileInfo = JSON.parse( this.fogg.sourceInfo 
);
                } catch ( e ) {
-                       mw.log( 'Error :: could not parse fogg sourceInfo' );
+                       mw.log.warn( 'Error :: could not parse fogg sourceInfo' 
);
                        return false;
                }
                return this.sourceFileInfo;
diff --git a/resources/mw.FormDataTransport.js 
b/resources/mw.FormDataTransport.js
index d2842d9..42ecc23 100644
--- a/resources/mw.FormDataTransport.js
+++ b/resources/mw.FormDataTransport.js
@@ -126,7 +126,7 @@
                     //failed to upload, try again in 3 seconds
                     _this.retries++;
                     if (_this.maxRetries > 0 && _this.retries >= 
_this.maxRetries) {
-                                               mw.log( 'max retries exceeded 
on unknown response' );
+                                               mw.warn( 'max retries exceeded 
on unknown response' );
                         //upload failed, raise response
                         _this.transportedCb(response);
                     } else {
@@ -142,7 +142,7 @@
             //failed to upload, try again in 3 second
             _this.retries++;
             if (_this.maxRetries > 0 && _this.retries >= _this.maxRetries) {
-                               mw.log( 'max retries exceeded on error event' );
+                               mw.warn( 'max retries exceeded on error event' 
);
                 _this.parseResponse(evt, _this.transportedCb);
             } else {
                                mw.log( 'retry #' + _this.retries + ' on error 
event' );
diff --git a/resources/mw.IframeTransport.js b/resources/mw.IframeTransport.js
index eaf2969..b73b6e4 100644
--- a/resources/mw.IframeTransport.js
+++ b/resources/mw.IframeTransport.js
@@ -48,14 +48,14 @@
                // attach an additional handler to the form, so, when 
submitted, it starts showing the progress
                // XXX this is lame .. there should be a generic way to 
indicate busy status...
                this.$form.submit( function() {
-                       // mw.log( "mw.IframeTransport::configureForm> 
submitting to iframe...", "debug" );
+                       // mw.log( "mw.IframeTransport::configureForm> 
submitting to iframe..." );
                        return true;
                } );
 
                // Set up the completion callback
                var _this = this;
                $j( '#' + this.iframeId ).load( function() {
-                       // mw.log( "mw.IframeTransport::configureForm> received 
result in iframe", "debug" );
+                       // mw.log( "mw.IframeTransport::configureForm> received 
result in iframe" );
                        _this.progressCb( 1.0 );
                        _this.processIframeResult( $j( this ).get( 0 ) );
                } );
diff --git a/resources/mw.Log.js b/resources/mw.Log.js
deleted file mode 100644
index 5da40ae..0000000
--- a/resources/mw.Log.js
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Logging library
- *
- *   Synopsis:
- *
- *    mw.log( "falls in the forest" );  // not logged, we start off at 
'silent' log level
- *
- *    // set the minimum level for a log message to be shown. Can be 'silent', 
'fatal', 'warn', 'info', 'debug'
- *    mw.log.level = 'debug'; // show just about everything
- *    mw.log( 'some random crap' ); // will be shown
- *
- *    mw.log.level = 'warn'; // show less stuff
- *
- *    mw.log( 'foo bar' ); // won't be shown, the default level for a log is 
'info'
- *
- *    mw.log( 'this is a warning', 'warn' ); // will be shown
- *
- *    var warnCute = mw.log.getLogger( 'cuteness', 'warn' );
- *    warnCute( 'overload!' ); // will log 'cuteness> overload!'
- *
- *    var logDebug = mw.log.getLogger( undefined, 'debug' );
- *    mw.log.level = 'debug';
- *    logDebug( "random spammy log for developers..." );   // will log "random 
spammy log for developers...";
- */
-
-( function( mw, $j ) {
-
-       /* how all the logging levels sort */
-       var priority = {
-               silent: 0,
-               fatal: 10,
-               warn: 20,
-               info: 30,
-               debug: 100
-       };
-
-       /**
-        * Log output to the console.
-        *
-        * In the case that the browser does not have a console available, one 
is created by appending a
-        * <div> element to the bottom of the body and then appending a <div> 
element to that for each
-        * message.
-        *
-        * @author Michael Dale <[email protected]>
-        * @author Trevor Parscal <[email protected]>
-        * @author Neil Kandalgaonkar <[email protected]>
-        * @param {string} string Message to output to console
-        * @param {string} optional, logging priority (see priority)
-        */
-       mw.log = function( s, level ) {
-
-               if ( typeof level === 'undefined' || ! priority.hasOwnProperty( 
level ) ) {
-                       level = 'info';
-               }
-
-               // don't show log message if lower priority than mw.log.level
-               if ( priority[ mw.log.level ] < priority[ level ] ) {
-                       return;
-               }
-
-               if ( typeof window.console !== 'undefined' && typeof 
window.console.log === 'function' ) {
-                       window.console.log( s );
-               } else {
-                       if ( typeof mw.log.makeConsole !== 'undefined' && 
mw.log.makeConsole ) {
-                               // Set timestamp
-                               var d = new Date();
-                               var time = ( pad( d.getHours(), 2 ) + ':' + 
pad( d.getMinutes(), 2 ) + pad( d.getSeconds(), 2 ) + pad( d.getMilliseconds(), 
3 ) );
-                               // Show a log box for console-less browsers
-                               var $log = $( '#mw-log-console' );
-                               if ( !$log.length ) {
-                                       $log = $( '<div 
id="mw-log-console"></div>' )
-                                               .css( {
-                                                       'position': 'fixed',
-                                                       'overflow': 'auto',
-                                                       'z-index': 500,
-                                                       'bottom': '0px',
-                                                       'left': '0px',
-                                                       'right': '0px',
-                                                       'height': '150px',
-                                                       'background-color': 
'white',
-                                                       'border-top': 'solid 
2px #ADADAD'
-                                               } )
-                                               .appendTo( 'body' );
-                               }
-                               $log.append(
-                                       $( '<div></div>' )
-                                               .css( {
-                                                       'border-bottom': 'solid 
1px #DDDDDD',
-                                                       'font-size': 'small',
-                                                       'font-family': 
'monospace',
-                                                       'padding': '0.125em 
0.25em'
-                                               } )
-                                               .text( s )
-                                               .append( '<span 
style="float:right">[' + time + ']</span>' )
-                               );
-                       }
-               }
-       };
-
-       // Logging is silent by default -- if you're debugging an app, figure 
out a way to turn it on
-       mw.log.level = 0;
-
-       /**
-        * Convenience function for logging cases where you want to repeatedly 
log with a prefix for each message,
-        * and/or at a particular logging level
-        *
-        * @param {string} prefix
-        * @param {string} level name
-        * @return {function} logging function which prepends that prefix, and 
logs at that level
-        */
-       mw.log.getLogger = function( prefixArg, level ) {
-               var prefix = typeof prefixArg === 'undefined' ? '' : prefixArg 
+ '> ';
-               return function( s ) {
-                       mw.log( prefix + s, level );
-               };
-       };
-
-       /**
-        * Helper function for logging date/time -- given number, return string 
zero-padded to requested length
-        * @param d {number} the number
-        * @param n {number} length
-        * @return {string}
-        */
-       function pad( d, n ) {
-               var s = d.toString();
-               while ( s.length < n ) {
-                       s = '0' + s;
-               }
-               return s;
-       }
-
-} )( window.mediaWiki, jQuery );
-
diff --git a/resources/mw.UploadWizardLicenseInput.js 
b/resources/mw.UploadWizardLicenseInput.js
index 2f52997..bb7adf7 100644
--- a/resources/mw.UploadWizardLicenseInput.js
+++ b/resources/mw.UploadWizardLicenseInput.js
@@ -346,13 +346,13 @@
                                        }
                                } );
                        } else {
-                               mw.log( "too many true values for a radio 
button!");
+                               mw.warn( "too many true values for a radio 
button!");
                        }
 
                } else if ( _this.type === 'checkbox' ) {
                        _this.setInputsIndividually( values );
                } else {
-                       mw.log( "impossible? UploadWizardLicenseInput type 
neither radio nor checkbox" );
+                       mw.warn( "impossible? UploadWizardLicenseInput type 
neither radio nor checkbox" );
                }
                // we use the selector because events can't be unbound unless 
they're in the DOM.
                _this.$selector.trigger( 'changeLicenses' );
@@ -500,7 +500,7 @@
                try {
                        ast = parser.wikiTextToAst( text );
                } catch (e) {
-                       mw.log( e.message );
+                       mw.warn( e.message );
                        return false;
                }
 
diff --git a/resources/mw.UploadWizardUpload.js 
b/resources/mw.UploadWizardUpload.js
index 40fd599..d77c52f 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -724,7 +724,7 @@
 
                var ok = function( data ) {
                        if ( !data || !data.query || !data.query.stashimageinfo 
) {
-                               
mw.log("mw.UploadWizardUpload::getStashImageInfo> No data? ");
+                               
mw.warn("mw.UploadWizardUpload::getStashImageInfo> No data? ");
                                callback( null );
                                return;
                        }
@@ -732,7 +732,7 @@
                };
 
                var err = function( code, result ) {
-                       mw.log( 'mw.UploadWizardUpload::getStashImageInfo> 
error: ' + code, 'debug' );
+                       mw.warn( 'mw.UploadWizardUpload::getStashImageInfo> 
error: ' + code );
                        callback( null );
                };
 
@@ -786,12 +786,12 @@
                                        return;
                                }
                        }
-                       mw.log("mw.UploadWizardUpload::getImageInfo> No data 
matching " + requestedTitle + " ? ");
+                       mw.warn("mw.UploadWizardUpload::getImageInfo> No data 
matching " + requestedTitle + " ? ");
                        callback( null );
                };
 
                var err = function( code, result ) {
-                       mw.log( 'mw.UploadWizardUpload::getImageInfo> error: ' 
+ code, 'debug' );
+                       mw.warn( 'mw.UploadWizardUpload::getImageInfo> error: ' 
+ code );
                        callback( null );
                };
 
@@ -849,7 +849,7 @@
                                        // the event with a null.
                                        $j.each( thumbnails, function( i, thumb 
) {
                                                if ( thumb.thumberror || ( ! ( 
thumb.thumburl && thumb.thumbwidth && thumb.thumbheight ) ) ) {
-                                                       mw.log( 
"mw.UploadWizardUpload::getThumbnail> thumbnail error or missing information" );
+                                                       mw.warn( 
"mw.UploadWizardUpload::getThumbnail> thumbnail error or missing information" );
                                                        $j.publishReady( key, 
null );
                                                        return;
                                                }
@@ -1116,7 +1116,7 @@
                                                placeImageCallback( x );
                                        } else {
                                                // something else went wrong, 
place broken image
-                                               mw.log( 'unexpected argument to 
thumbnails event: ' + x );
+                                               mw.warn( 'unexpected argument 
to thumbnails event: ' + x );
                                                placeImageCallback( null );
                                        }
                                }

-- 
To view, visit https://gerrit.wikimedia.org/r/79917
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb7121fa85ce36655749625c0d5447844c3387a0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to