Implements the ConsoleMessage object. For details about the sample code, see onConsole.
The initial APIs of this component are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
The initial APIs of this class are supported since API version 8.
The sample effect is subject to the actual device.
constructor(message: string, sourceId: string, lineNumber: number, messageLevel: MessageLevel)
Constructs a ConsoleMessage object.
This API is supported since API version 8 and deprecated since API version 9. You are advised to use constructor instead.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| message | string | Yes | Log output information of ConsoleMessage. |
| sourceId | string | Yes | Path and name of the web page source file. |
| lineNumber | number | Yes | Line number of ConsoleMessage. |
| messageLevel | MessageLevel | Yes | Log level of ConsoleMessage. |
constructor()
Constructs a ConsoleMessage object.
System capability: SystemCapability.Web.Webview.Core
getLineNumber(): number
Obtains the number of rows in this console message.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| number | Number of rows in the console message. |
getMessage(): string
Obtains the log information of this console message.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| string | Log information of the console message. |
getMessageLevel(): MessageLevel
Obtains the level of this console message.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| MessageLevel | Level of the console message. |
getSourceId(): string
Obtains the path and name of the web page source file.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| string | Path and name of the web page source file. |
getSource(): ConsoleMessageSource
Obtains the log source of this console message.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| ConsoleMessageSource | Log source of the console message. |