Firebug tutorial–logging, Profiling and CommandLine (part I)

Source: Internet
Author: User
Tags assert
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.

1 2 3 4 5 6 7 8 9 10

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.