1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.webkit; 18 19/** 20 * Public class representing a JavaScript console message from WebCore. This could be a issued 21 * by a call to one of the <code>console</code> logging functions (e.g. 22 * <code>console.log('...')</code>) or a JavaScript error on the page. To receive notifications 23 * of these messages, override the 24 * {@link WebChromeClient#onConsoleMessage(ConsoleMessage)} function. 25 */ 26public class ConsoleMessage { 27 28 // This must be kept in sync with the WebCore enum in WebCore/page/Console.h 29 public enum MessageLevel { 30 TIP, 31 LOG, 32 WARNING, 33 ERROR, 34 DEBUG 35 }; 36 37 private MessageLevel mLevel; 38 private String mMessage; 39 private String mSourceId; 40 private int mLineNumber; 41 42 public ConsoleMessage(String message, String sourceId, int lineNumber, MessageLevel msgLevel) { 43 mMessage = message; 44 mSourceId = sourceId; 45 mLineNumber = lineNumber; 46 mLevel = msgLevel; 47 } 48 49 public MessageLevel messageLevel() { 50 return mLevel; 51 } 52 53 public String message() { 54 return mMessage; 55 } 56 57 public String sourceId() { 58 return mSourceId; 59 } 60 61 public int lineNumber() { 62 return mLineNumber; 63 } 64}; 65