Class (ConsoleMessage)

Implements the ConsoleMessage object. For details about the sample code, see onConsole.

NOTE

  • 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(deprecated)

constructor(message: string, sourceId: string, lineNumber: number, messageLevel: MessageLevel)

Constructs a ConsoleMessage object.

NOTE

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.

constructor9+

constructor()

Constructs a ConsoleMessage object.

System capability: SystemCapability.Web.Webview.Core

getLineNumber

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

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

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

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.

getSource23+

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.