Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/common/bidi/log.py
1864 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
from dataclasses import dataclass
19
20
21
class LogEntryAdded:
22
event_class = "log.entryAdded"
23
24
@classmethod
25
def from_json(cls, json):
26
if json["type"] == "console":
27
return ConsoleLogEntry.from_json(json)
28
elif json["type"] == "javascript":
29
return JavaScriptLogEntry.from_json(json)
30
31
32
@dataclass
33
class ConsoleLogEntry:
34
level: str
35
text: str
36
timestamp: str
37
method: str
38
args: list[dict]
39
type_: str
40
41
@classmethod
42
def from_json(cls, json):
43
return cls(
44
level=json["level"],
45
text=json["text"],
46
timestamp=json["timestamp"],
47
method=json["method"],
48
args=json["args"],
49
type_=json["type"],
50
)
51
52
53
@dataclass
54
class JavaScriptLogEntry:
55
level: str
56
text: str
57
timestamp: str
58
stacktrace: dict
59
type_: str
60
61
@classmethod
62
def from_json(cls, json):
63
return cls(
64
level=json["level"],
65
text=json["text"],
66
timestamp=json["timestamp"],
67
stacktrace=json["stackTrace"],
68
type_=json["type"],
69
)
70
71
72
class LogLevel:
73
"""Represents log level."""
74
75
DEBUG = "debug"
76
INFO = "info"
77
WARN = "warn"
78
ERROR = "error"
79
80