jQuery to Firebug Logging


/ Published in: jQuery
Save to your folder(s)

A simple but powerful interface for allowing firebug access functions in the jQuery chain.

See the link above to check out the functions it accepts.


Copy this code and paste it in your HTML
  1. $.enableConsole = false;
  2. $.fn.console = $.console = function(method){
  3. if (window.console && console[method] && $.enableConsole)
  4. console[method].apply(this, [].splice.call(arguments,1))
  5. return this;
  6. }
  7.  
  8. // When debugging code, be sure to set:
  9. $.enableConsole = true; // Or none of your lines will reach the console
  10.  
  11. // You can call any firebug functions through either the direct jQuery object, or in a chain:
  12. $.console('debug', 'This is some %s text', 'debugging');
  13.  
  14. // The best part is the ability to use the firebug console chain easily:
  15. var color = '#FFF';
  16. $('#someElement').css('backgroundColor', color).console('log', 'Changing the background color to "%s"', color);
  17.  
  18. // And the access to the other functions of the firebug console, like time/timeEnd
  19. $('#someElement').console('time', 'timing foo').animate({...}).console('timeEnd', 'timing foo');

URL: http://getfirebug.com/logging.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.