* Installer for Oracle fixes
[mediawiki.git] / resources / mediawiki / mediawiki.log.js
blob52cbe48228052a919353fe265643d4b44ce5b50c
1 /*
2  * Debug output logging
3  */
5 ( function( $, mw ) {
7 /* Extension */
9 $.extend( mw, {
10         
11         /* Functions */
12         
13         /**
14          * Log output to the console
15          * 
16          * In the case that the browser does not have a console available, one is created by appending a <div> element to
17          * the bottom of the body and then appending a <div> element to that for each message.
18          *
19          * @author Michael Dale <mdale@wikimedia.org>, Trevor Parscal <tparscal@wikimedia.org>
20          * @param {string} string message to output to console
21          */
22         'log': function( string ) {
23                 // Allow log messages to use a configured prefix                
24                 if ( mw.config.exists( 'mw.log.prefix' ) ) {
25                         string = mw.config.get( 'mw.log.prefix' ) + string;             
26                 }
27                 // Try to use an existing console
28                 if ( typeof window.console !== 'undefined' && typeof window.console.log == 'function' ) {
29                         window.console.log( string );
30                 } else {
31                         // Show a log box for console-less browsers
32                         var $log = $( '#mw_log_console' );
33                         if ( !$log.length ) {
34                                 $log = $( '<div id="mw_log_console"></div>' )
35                                         .css( {
36                                                 'position': 'absolute',
37                                                 'overflow': 'auto',
38                                                 'z-index': 500,
39                                                 'bottom': '0px',
40                                                 'left': '0px',
41                                                 'right': '0px',
42                                                 'height': '150px',
43                                                 'background-color': 'white',
44                                                 'border-top': 'solid 1px #DDDDDD'
45                                         } )
46                                         .appendTo( $( 'body' ) );
47                         }
48                         $log.append(
49                                 $( '<div></div>' )
50                                         .text( string )
51                                         .css( {
52                                                 'border-bottom': 'solid 1px #DDDDDD',
53                                                 'font-size': 'small',
54                                                 'font-family': 'monospace',
55                                                 'padding': '0.125em 0.25em'
56                                         } )
57                         );
58                 }
59         }
60 } );
62 } )( jQuery, mediaWiki );