no_console.js - When there is no Firebug

(Javascript)

Some browsers support the global console as a way to log helpful information during development and/or debugging:

var foo = function (some_param) {
  console.log("Called foo with param value: %o", some_param);
}

Some browser extensions like Firebug provide a more powerful console.

However - when the script is run in a browser with no global console the result is usually an error (accessing a non-existent variable).

To work around this problem I wrote:

This script does two things:

  1. If there is no global console create one - the object has a set of no-op functions based on the Firebug Console API as of 10/April/2010.

  2. Creates a global dconsole object - this is a console which will be a copy of the global console if a global variable DEBUG_CONSOLE is set to a truthy value. Note that if the global console is already a no-op console then logging via dconsole will be no-ops as well.

BradsWiki: no console.js (last edited 2010-12-03 00:12:31 by BradleyDean)