FIREBUG TUTORIAL
Section 1:console tab:logging, PROFILING and COMMANDLINE (part II)
Overview of Console Tab
This tab is mainly used for logging. It also can be used as CommandLine windows (like immediate windows in Microsoft Visual Studio) while you are debugging the J Avascript. It can be used for monitoring the execution of the Javascript code by using Profiling service.
The following topic would be covered in this section. Logging in Firebug (with String substitution pattern) Grouping The logs or messages Console.dir and Console.dirxml Assert Ion (Console.assert ()) Tracing (Console.trace ()) Timing (measuring the time of your code) Javascript Profiler (a int Roduction in this tutorial, the details would be covered in next tutorial.)
#1. Logging in Firebug
Firebug supports logging in Console tab. So, don ' t need to use alert (' something ') or document.write (' something ') anymore.
There are five types of logging in Firebug. Console.log:Write a message without icon. Console.debug:Writes a message to the console, including a hyperlink to the line where it is called Console.error (): Writes a message to the console with the visual ' Error ' icon and color coding and a hyperlink to the ' line where it is a CAL Led. Console.info (): Writes a message to the console with the visual ' Info ' icon and color coding and a hyperlink to the ' line where it was called. Console.warn (): Writes a message to the console with the visual "Warning" icon and color coding and a hyperlink to the Li NE where it was called.
Example code:open the HTM file called "Plain html" or create one HTML file. Paste the following code with <body> tag.
1 2 3 4 5 6 7 |
<script language= "javascript" type= "Text/javascript" > Console.log (' This was log message '); Console.debug (' This are debug message '); Console.error (' This are error message '); Console.info (' This is info '); Console.warn (' This are warning message '); </script> |
You'll get the following output. If you click Hyperlink (' Test.htm ' in the ' case), it'll take you to Script tab and would highlight the line that wrote This message.
String substitution Patterns
String substitution parterns can is used in Console.log, Console.info, Console.debug, Console.warn and Console.error. You can use the same way so we used in C + +.
%s |
String |
%d,%i |
Integer (numeric formatting is not yet supported) |
%f |
Floating point number (numeric formatting isn't yet supported) |
%o |
Object hyperlink |
Example:
Note:i'll use Console.log in the example below even all console objects (Console.log, Console.info, Console.debug, cons Ole.warn and Console.error) support string substitution. Remove "Script" tag that we pasted for the previous example. Paste the code below within <body> tag.