2 * Implementation for mediaWiki.log stub
8 * Log output to the console.
10 * In the case that the browser does not have a console available, one is created by appending a
11 * <div> element to the bottom of the body and then appending a <div> element to that for each
14 * @author Michael Dale <mdale@wikimedia.org>
15 * @author Trevor Parscal <tparscal@wikimedia.org>
16 * @param {string} string Message to output to console
18 mw
.log = function( string
) {
19 // Allow log messages to use a configured prefix to identify the source window (ie. frame)
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 console
.log( string
);
29 var time
= ( d
.getHours() < 10 ? '0' + d
.getHours() : d
.getHours() ) +
30 ':' + ( d
.getMinutes() < 10 ? '0' + d
.getMinutes() : d
.getMinutes() ) +
31 ':' + ( d
.getSeconds() < 10 ? '0' + d
.getSeconds() : d
.getSeconds() ) +
32 '.' + ( d
.getMilliseconds() < 10 ? '00' + d
.getMilliseconds() : ( d
.getMilliseconds() < 100 ? '0' + d
.getMilliseconds() : d
.getMilliseconds() ) );
33 // Show a log box for console-less browsers
34 var $log
= $( '#mw-log-console' );
36 $log
= $( '<div id="mw-log-console"></div>' )
45 'background-color': 'white',
46 'border-top': 'solid 2px #ADADAD'
49 .css( 'padding-bottom', '150px' ) // don't hide anything
55 'border-bottom': 'solid 1px #DDDDDD',
57 'font-family': 'monospace',
58 'white-space': 'pre-wrap',
59 'padding': '0.125em 0.25em'
62 .prepend( '<span style="float:right">[' + time
+ ']</span>' )