Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/selenium-webdriver/bidi/logEntries.js
2884 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
'use strict'
19
20
const { Source } = require('./scriptTypes')
21
22
/**
23
* Represents a base log entry.
24
* Described in https://w3c.github.io/webdriver-bidi/#types-log-logentry.
25
*/
26
class BaseLogEntry {
27
/**
28
* Creates a new instance of BaseLogEntry.
29
* @param {string} level - The log level.
30
* @param {source} source - Script Source
31
* @param {string} text - The log source.
32
* @param {string} text - The log text.
33
* @param {number} timeStamp - The log timestamp.
34
* @param {string} stackTrace - The log stack trace.
35
*/
36
constructor(level, source, text, timeStamp, stackTrace) {
37
this._level = level
38
this._source = new Source(source)
39
this._text = text
40
this._timeStamp = timeStamp
41
this._stackTrace = stackTrace
42
}
43
44
/**
45
* Gets the log level.
46
* @returns {string} The log level.
47
*/
48
get level() {
49
return this._level
50
}
51
52
/**
53
* Gets the log text.
54
* @returns {string} The log text.
55
*/
56
get text() {
57
return this._text
58
}
59
60
/**
61
* Gets the log timestamp.
62
* @returns {number} The log timestamp.
63
*/
64
get timeStamp() {
65
return this._timeStamp
66
}
67
68
/**
69
* Gets the log stack trace.
70
* @returns {string} The log stack trace.
71
*/
72
get stackTrace() {
73
return this._stackTrace
74
}
75
76
get source() {
77
return this._source
78
}
79
}
80
81
/**
82
* Represents a generic log entry.
83
* @class
84
* @extends BaseLogEntry
85
*/
86
class GenericLogEntry extends BaseLogEntry {
87
/**
88
* Creates an instance of GenericLogEntry.
89
* @param {string} level - The log level.
90
* @param {source} source - Script Source
91
* @param {string} text - The log text.
92
* @param {Date} timeStamp - The log timestamp.
93
* @param {string} type - The log type.
94
* @param {string} stackTrace - The log stack trace.
95
*/
96
constructor(level, source, text, timeStamp, type, stackTrace) {
97
super(level, source, text, timeStamp, stackTrace)
98
this._type = type
99
}
100
101
/**
102
* Gets the log type.
103
* @returns {string} The log type.
104
*/
105
get type() {
106
return this._type
107
}
108
}
109
110
/**
111
* Represents a log entry for console logs.
112
* @class
113
* @extends GenericLogEntry
114
*/
115
class ConsoleLogEntry extends GenericLogEntry {
116
constructor(level, source, text, timeStamp, type, method, args, stackTrace) {
117
super(level, source, text, timeStamp, type, stackTrace)
118
this._method = method
119
this._args = args
120
}
121
122
/**
123
* Gets the method associated with the log entry.
124
* @returns {string} The method associated with the log entry.
125
*/
126
get method() {
127
return this._method
128
}
129
/**
130
* Gets the arguments associated with the log entry.
131
* @returns {Array} The arguments associated with the log entry.
132
*/
133
get args() {
134
return this._args
135
}
136
}
137
138
/**
139
* Represents a log entry for JavaScript logs.
140
* @class
141
* @extends GenericLogEntry
142
*/
143
class JavascriptLogEntry extends GenericLogEntry {
144
constructor(level, source, text, timeStamp, type, stackTrace) {
145
super(level, source, text, timeStamp, type, stackTrace)
146
}
147
}
148
149
// PUBLIC API
150
151
module.exports = {
152
BaseLogEntry,
153
GenericLogEntry,
154
ConsoleLogEntry,
155
JavascriptLogEntry,
156
}
157
158