10 * Log output to the console
12 * In the case that the browser does not have a console available, one is created by appending a <div> element to
13 * the bottom of the body and then appending a <div> element to that for each message.
15 * @author Michael Dale <mdale@wikimedia.org>, Trevor Parscal <tparscal@wikimedia.org>
16 * @param {string} string message to output to console
18 mediaWiki
.log = function( string
) {
19 // Allow log messages to use a configured prefix
20 if ( mw
.config
.exists( 'mw.log.prefix' ) ) {
21 string
= mw
.config
.get( 'mw.log.prefix' ) + string
;
23 // Try to use an existing console
24 if ( typeof window
.console
!== 'undefined' && typeof window
.console
.log
== 'function' ) {
25 window
.console
.log( string
);
27 // Show a log box for console-less browsers
28 var $log
= $( '#mw_log_console' );
30 $log
= $( '<div id="mw_log_console"></div>' )
32 'position': 'absolute',
39 'background-color': 'white',
40 'border-top': 'solid 1px #DDDDDD'
42 .appendTo( $( 'body' ) );
48 'border-bottom': 'solid 1px #DDDDDD',
50 'font-family': 'monospace',
51 'padding': '0.125em 0.25em'