Navigation Menu

Skip to content

acuppy/jquery.log.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jQuery console.log() Wrapper

jQuery logger is a tool to inobtrusively trigger a console.log message with an associated jQuery element. This code can be turned on/off for development/production without being removed. The logger supports multiple log levels, grouped messages and a backtrace.

Usage

In-obtrusively log information to an associated element(s) by including the jQuery logger to the chain

$('div.title').show().log('Title displayed');

This will output a console.log message with the included jQuery element as an associated element

Extended default settings by first calling $.log function with a hash of parameters

$.log({
  /* activate the logger */
  active: true,

  /* outputs console.trace() after the log has been written */
  backtrace: false,

  /* enable grouping of console.log */
  group: true,

  /* auto collapses console.log groups */
  collapsed: false,

   /* available log levels:  info, debug, warn, error */
  log_level: 'debug'
});

Depending on current log_level only messsage of greater severity are passed.

$.log({
  log_level: 'warn'
});

To set a message severity, provide the 2nd paramater a string. If the conditions above are set, then this message would not appear in the console.log

$('div.title').show().log('Title displayed', 'info');

but this one, would...

$('div.title').hide().log('Title hidden', 'warn');