Info

URL: http://www.talkapex.com/2011/01/console-wrapper-previously-js-logger.html
APEX Ver#: 4.0.2.00.06
Instructions:

This is a live demo of the Console Wrapper. Project is hosted on Google: http://code.google.com/p/js-console-wrapper

To view the console output:

- Firefox: F12
- Safari: Ctrl+Alt+C
- Chrome: Ctrl+Shift+J
- IE: Will not work but no errors should appear

Triggering Region

For Examples
span 1
span 2

Demo JavaScript

function myFn(pA, pB){
  $.console.logParams();
  //do something as part of function
}//myFn

$(document).ready(function() {
  if (window.console) {
    //Enable logging mode
    $.console.setLevel('log');
    
    // 2 ways of calling Console
    // *** Standalone ***
    $.console.group('*** Stand Alone ***');
    $.console.log('Current log level: ', $.console.getLevel());
    $.console.warn('This is a warning message');
    $.console.groupEnd();
    
    // *** jQuery Chained Function ***
    // assumes you have a <span class="red">...</span> tag
    $.console.group('*** jQuery Chained Function ***');
    $('.red').log('Before Red').css({color:'red'}).log('After Red');
    $.console.groupEnd();
    
    // Warning for chained function
    $.console.group('*** jQuery Chained Function (warn) ***');
    $('.red').log('warn','Before Red').css({color:'red'}).log('After Red');
    $.console.groupEnd();
    
    // *** logParams ***
    myFn(1,2,3);
  }
  else {
    // Console does not exist
    window.alert('Browser does not support "console" or must enable "console"'); 
  }
});