From 7b02e924b0a44991d60337f0f1516355bd083afe Mon Sep 17 00:00:00 2001 From: Scott Main Date: Fri, 29 Jan 2010 10:28:18 -0800 Subject: docs: update web page debugging with info about page and line numbering in the log. --- docs/html/guide/developing/debug-tasks.jd | 50 ++++++++++++++++++------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/docs/html/guide/developing/debug-tasks.jd b/docs/html/guide/developing/debug-tasks.jd index a980efc2fe0b..500ef588dc4c 100644 --- a/docs/html/guide/developing/debug-tasks.jd +++ b/docs/html/guide/developing/debug-tasks.jd @@ -58,8 +58,8 @@ Log.i("MyActivity", "MyClass.getView() — get item number " + position);
 I/MyActivity( 1557): MyClass.getView() — get item number 1
 
-

Logcat is also the place to look when debugging a web page in the Android browser. All -browser bugs will be output to logcat with the {@code WebCore} tag. +

Logcat is also the place to look when debugging a web page in the Android Browser app. See +Debugging Web Pages below.

For more information about all the development tools provided with the Android SDK, see the

Debugging Web Pages

-

If you're developing a web application for Android devices, you can debug your JavaScript on -Android using the Console APIs, which will output messages to logcat. If you're familiar +

If you're developing a web application for Android devices, you can debug your JavaScript in the +Android Browser using the Console APIs, which will output messages to logcat. If you're familiar debugging web pages with Firefox's FireBug or WebKit's Web Inspector, then you're probably familiar -with the Console APIs. The Android Browser (and {@link android.webkit.WebChromeClient}) supports +with the Console APIs. The Android Browser (and the {@link android.webkit.WebChromeClient}) supports most of the same APIs.

When you call a function from the Console APIs (in the DOM's {@code window.console} object), @@ -162,19 +162,28 @@ console.log("Hello World");

Then the logcat output from the Android Browser will look like this:

-W/browser ( 202): Console: Hello World :0
+W/browser ( 202): Console: Hello World http://www.example.com/hello.html :82
 
-

Note: All Console messages from the Android -Browser are tagged with the name "browser" on Android platforms running API Level 7 or higher and -tagged with the name "WebCore" for platforms running API Level 6 or lower.

- -

Not all of the Console APIs available in Firefox or other WebKit browsers are implemented -on Android. Mostly, you need to depend on basic text logging provided by -functions like {@code console.log(String)}, {@code console.info(String)}, {@code -console.warn(String)}, and {@code console.error(String)}. Although other Console functions may not -be implemented, they will not raise run-time errors, but will simply not behave as you might -expect.

+

All Console messages from the Android Browser are tagged with the name "browser" on Android +platforms running API Level 7 or higher. On platforms running API Level 6 or lower, Browser +messages are tagged with the name "WebCore". The Android Browser also formats console messages +with the log message +preceded by "Console:" and then followed by the address and line number where the +message occurred. (The format for the address and line number will appear different from the example +above on platforms running API Level 6 or lower.)

+ +

The Android Browser (and {@link android.webkit.WebChromeClient}) does not implement all of the +Console APIs provided by Firefox or other WebKit-based browsers. Primarily, you need to depend +on the basic text logging functions:

+ +

Although the Android Browser may not fully implement other Console functions, they will not raise +run-time errors, but may not behave the same as they do on other desktop browsers.

If you've implemented a custom {@link android.webkit.WebView} in your application, then in order to receive messages that are sent through the Console APIs, you must provide a {@link @@ -185,7 +194,7 @@ android.webkit.WebView} in your application, you can log debug messages like thi

 myWebView.setWebChromeClient(new WebChromeClient() {
   public void onConsoleMessage(String message, int lineNumber, String sourceID) {
-    Log.d("MyApplication", message);
+    Log.d("MyApplication", message + " -- From line " + lineNumber + " of " + sourceID);
   }
 });
 
@@ -195,13 +204,14 @@ within your {@link android.webkit.WebView}.

When the "Hello World" log is executed through your {@link android.webkit.WebView}, it will now look like this:

-D/MyApplication ( 430): Hello World
+D/MyApplication ( 430): Hello World -- From line 82 of http://www.example.com/hello.html
 

Note: The {@link android.webkit.WebChromeClient#onConsoleMessage(String,int,String) onConsoleMessage()} callback -method was added with API Level 7. If you are targetting platforms running API Level 6 or lower, -then your Console messages will automatically be sent to logcat with the "WebCore" logging tag.

+method was added with API Level 7. If you are using a custom {@link +android.webkit.WebView} on a platform running API Level 6 or lower, then your Console messages will +automatically be sent to logcat with the "WebCore" logging tag.

-- cgit v1.2.3-59-g8ed1b