• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Class (ConsoleMessage)
2
3Implements the **ConsoleMessage** object. For details about the sample code, see [onConsole](./arkts-basic-components-web-events.md#onconsole).
4
5> **NOTE**
6>
7> - 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.
8>
9> - The initial APIs of this class are supported since API version 8.
10>
11> - You can preview how this component looks on a real device, but not in DevEco Studio Previewer.
12
13## constructor
14
15constructor(message: string, sourceId: string, lineNumber: number, messageLevel: MessageLevel)
16
17Constructs a **ConsoleMessage** object.
18
19> **NOTE**
20>
21> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [constructor](#constructor9) instead.
22
23**System capability**: SystemCapability.Web.Webview.Core
24
25## constructor<sup>9+</sup>
26
27constructor()
28
29Constructs a **ConsoleMessage** object.
30
31**System capability**: SystemCapability.Web.Webview.Core
32
33## getLineNumber
34
35getLineNumber(): number
36
37Obtains the number of rows in this console message.
38
39**System capability**: SystemCapability.Web.Webview.Core
40
41**Return value**
42
43| Type    | Description                  |
44| ------ | -------------------- |
45| number | Number of rows in the console message.|
46
47## getMessage
48
49getMessage(): string
50
51Obtains the log information of this console message.
52
53**System capability**: SystemCapability.Web.Webview.Core
54
55**Return value**
56
57| Type    | Description                    |
58| ------ | ---------------------- |
59| string | Log information of the console message.|
60
61## getMessageLevel
62
63getMessageLevel(): MessageLevel
64
65Obtains the level of this console message.
66
67**System capability**: SystemCapability.Web.Webview.Core
68
69**Return value**
70
71| Type                               | Description                    |
72| --------------------------------- | ---------------------- |
73| [MessageLevel](./arkts-basic-components-web-e.md#messagelevel) | Level of the console message.|
74
75## getSourceId
76
77getSourceId(): string
78
79Obtains the path and name of the web page source file.
80
81**System capability**: SystemCapability.Web.Webview.Core
82
83**Return value**
84
85| Type    | Description           |
86| ------ | ------------- |
87| string | Path and name of the web page source file.|
88