-/**
+/*!
* Logger for MediaWiki javascript.
* Implements the stub left by the main 'mediawiki' module.
*
( function ( mw, $ ) {
+ // Reference to dummy
+ // We don't need the dummy, but it has other methods on it
+ // that we need to restore afterwards.
+ var original = mw.log,
+ slice = Array.prototype.slice;
+
/**
- * Logs a message to the console.
+ * Logs a message to the console in debug mode.
*
* In the case the browser does not have a console API, a console is created on-the-fly by appending
- * a <div id="mw-log-console"> element to the bottom of the body and then appending this and future
+ * a `<div id="mw-log-console">` element to the bottom of the body and then appending this and future
* messages to that, instead of the console.
*
- * @param {String} First in list of variadic messages to output to console.
+ * @member mw.log
+ * @param {string...} msg Messages to output to console.
*/
- mw.log = function ( /* logmsg, logmsg, */ ) {
+ mw.log = function () {
// Turn arguments into an array
- var args = Array.prototype.slice.call( arguments ),
+ var args = slice.call( arguments ),
// Allow log messages to use a configured prefix to identify the source window (ie. frame)
prefix = mw.config.exists( 'mw.log.prefix' ) ? mw.config.get( 'mw.log.prefix' ) + '> ' : '';
// Try to use an existing console
- if ( window.console !== undefined && $.isFunction( window.console.log ) ) {
+ // Generally we can cache this, but in this case we want to re-evaluate this as a
+ // global property live so that things like Firebug Lite can take precedence.
+ if ( window.console && window.console.log ) {
args.unshift( prefix );
window.console.log.apply( window.console, args );
return;
hovzer.update();
}
$log.append(
- $( '<div></div>' )
+ $( '<div>' )
.css( {
borderBottom: 'solid 1px #DDDDDD',
fontSize: 'small',
} );
};
+ // Restore original methods
+ mw.log.warn = original.warn;
+ mw.log.deprecate = original.deprecate;
+
}( mediaWiki, jQuery ) );