Path: blob/trunk/py/selenium/webdriver/common/bidi/log.py
1864 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617from dataclasses import dataclass181920class LogEntryAdded:21event_class = "log.entryAdded"2223@classmethod24def from_json(cls, json):25if json["type"] == "console":26return ConsoleLogEntry.from_json(json)27elif json["type"] == "javascript":28return JavaScriptLogEntry.from_json(json)293031@dataclass32class ConsoleLogEntry:33level: str34text: str35timestamp: str36method: str37args: list[dict]38type_: str3940@classmethod41def from_json(cls, json):42return cls(43level=json["level"],44text=json["text"],45timestamp=json["timestamp"],46method=json["method"],47args=json["args"],48type_=json["type"],49)505152@dataclass53class JavaScriptLogEntry:54level: str55text: str56timestamp: str57stacktrace: dict58type_: str5960@classmethod61def from_json(cls, json):62return cls(63level=json["level"],64text=json["text"],65timestamp=json["timestamp"],66stacktrace=json["stackTrace"],67type_=json["type"],68)697071class LogLevel:72"""Represents log level."""7374DEBUG = "debug"75INFO = "info"76WARN = "warn"77ERROR = "error"787980