Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
94 lines (76 sloc) 4.67 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="SpyBug.min.1.0.0.js"></script>
<title>SpyBug</title>
</head>
<body>
<h2>SpyBug</h2>
<h6>version 1.0.0</h6>
<h4>Developed by Rishabh Rao</h4>
<p><a href="http://rishabhsrao.wordpress.com">rishabhsrao.wordpress.com</a><br />
<a href="mailto:rishabhsrao@gmail.com">rishabhsrao@gmail.com</a><br />
<a href="http://twitter.com/rishabhsrao">twitter.com/rishabhsrao</a></p>
<h5>SpyBug provides a simple framework for logging and debugging using the browser's native console.</h5>
<p>This sample demonstrates the use of SpyBug.</p>
<p>If you are using <a href="http://getfirefox.com">Mozilla Firefox</a> 3+, then open <a href="http://getfirebug.com">Firebug</a> by pressing F12 or clicking the bug icon in the right-side corner. <a href="http://getfirebug.com">If you do not have Firebug, then install it now!</a><br />
If you are using Internet Explorer 8+, then get <a href="http://getfirefox.com">Mozilla Firefox</a>!<br />
If you have got no choice, then Open Tools >> Developer Tools and select Script > Console.<br />
If you are using any other browser, then read the it's help/documentation to see if it supports a console.<br />
If it doesn't, then get <a href="http://getfirefox.com">Mozilla Firefox</a>!</p>
<p>To understand this example, view the source of this HTML file or see the code below:</p>
<pre>
// Create the SpyBug object. You'll be using this object to log your messages to the console.
// Logging is enabled by default initially.
var spybug = new SpyBug();
// These lines demonstrate the various log messages available.
// Use the spy method to show messages on the console.
spybug.spy("This is an information message.", spybug.INFO);
spybug.spy("This is a debug message.", spybug.LOG);
// Note that Internet Explorer may not support the type WARN.
spybug.spy("This is a warning message.", spybug.WARN);
spybug.spy("This is an error message.", spybug.ERROR);
spybug.spy("This is a log message.", spybug.LOG);
spybug.spy("This message will use the default type i.e. LOG.");
spybug.spy("Disabling logging...", spybug.INFO);
// You can disable logging by passing false to the setLoggingStatus method as an argument.
spybug.setLoggingStatus(false);
spybug.spy("Oops, this message will not be shown on the console because logging is disabled.", spybug.ERROR);
// You can enable logging again by passing true to the setLoggingStatus method as an argument.
spybug.setLoggingStatus(true);
spybug.spy("Logging enabled...", spybug.INFO);
// The getLogingStatus method tells you whether logging is enabled or disabled.
spybug.spy("Logging is " + (spybug.getLoggingStatus() ? "enabled" : "disabled"), spybug.INFO);
// The toString method simply prints a short message and the current logging status.
spybug.spy(spybug.toString());
</pre>
<script type="text/javascript">
// Create the SpyBug object. You'll be using this object to log your messages to the console.
// Logging is enabled by default initially.
var spybug = new SpyBug();
// These lines demonstrate the various log messages available.
// Use the spy method to show messages on the console.
spybug.spy("This is an information message.", spybug.INFO);
spybug.spy("This is a debug message.", spybug.LOG);
// Note that Internet Explorer may not support the type WARN.
spybug.spy("This is a warning message.", spybug.WARN);
spybug.spy("This is an error message.", spybug.ERROR);
spybug.spy("This is a log message.", spybug.LOG);
spybug.spy("This message will use the default type i.e. LOG.");
spybug.spy("Disabling logging...", spybug.INFO);
// You can disable logging by passing false to the setLoggingStatus method as an argument.
spybug.setLoggingStatus(false);
spybug.spy("Oops, this message will not be shown on the console because logging is disabled.", spybug.ERROR);
// You can enable logging again by passing true to the setLoggingStatus method as an argument.
spybug.setLoggingStatus(true);
spybug.spy("Logging enabled...", spybug.INFO);
// The getLogingStatus method tells you whether logging is enabled or disabled.
spybug.spy("Logging is " + (spybug.getLoggingStatus() ? "enabled" : "disabled"), spybug.INFO);
// The toString method simply prints a short message and the current logging status.
spybug.spy(spybug.toString());
</script>
<p>Hope you liked SpyBug! Happy debugging!</p>
</body>
</html>