jQuery plugin for browser log messaging. It has the capability of attaching hierarchichal levels to log messages. And it can be enabled or disabled at runtime, thus preventing unnecessary logging or the ability to "debug" code after deployment.
The logger has four levels, in hierarchical order they are:
- DEBUG
- INFO
- WARNING
- ERROR
The logger can be either enabled or disabled at runtime. The logger is disabled by default and the default level is 'ERROR'.
You can initialize the logger settings like this:
var level = "DEBUG"; // "DEBUG", "INFO", "WARNING", or "ERROR"
var enabled = true; // true (enabled) or false (disabled)
$.log.init(level, enabled);
You can enable or disable the logger by doing:
$.log.settings.enabled = false; //disable
$.log.settings.enabled = true; // enable again
To change the logger level:
$.log.settings.level = "DEBUG";
$.log.settings.level = "INFO";
$.log.settings.level = "WARNING";
$.log.settings.level = "ERROR";
To start using the logger, you can do so like this:
$.log("my message");
In this case the logger will use the default log level of ERROR. You are encouraged to configure the logger level, even though it is not required.
You may specify the level to use for the messsage you want to log. You can do it as follows:
$.log("my debug message", 'DEBUG');
Alternatively you can use the specific methods for the different log levels:
$.log.debug("my debug message");
$.log.info("my info message");
$.log.warning("my warning message");
$.log.error("my error message");
Firefox: Requires Firebug's console
Chrome: Supported in ALL versions
IE: Not supported
Copyright (c) 2011 Cesar Arevalo [email protected]
This library is licensed under the MIT license:
http://opensource.org/licenses/mit-license.php