Path: blob/trunk/javascript/selenium-webdriver/bidi/logEntries.js
2884 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.1617'use strict'1819const { Source } = require('./scriptTypes')2021/**22* Represents a base log entry.23* Described in https://w3c.github.io/webdriver-bidi/#types-log-logentry.24*/25class BaseLogEntry {26/**27* Creates a new instance of BaseLogEntry.28* @param {string} level - The log level.29* @param {source} source - Script Source30* @param {string} text - The log source.31* @param {string} text - The log text.32* @param {number} timeStamp - The log timestamp.33* @param {string} stackTrace - The log stack trace.34*/35constructor(level, source, text, timeStamp, stackTrace) {36this._level = level37this._source = new Source(source)38this._text = text39this._timeStamp = timeStamp40this._stackTrace = stackTrace41}4243/**44* Gets the log level.45* @returns {string} The log level.46*/47get level() {48return this._level49}5051/**52* Gets the log text.53* @returns {string} The log text.54*/55get text() {56return this._text57}5859/**60* Gets the log timestamp.61* @returns {number} The log timestamp.62*/63get timeStamp() {64return this._timeStamp65}6667/**68* Gets the log stack trace.69* @returns {string} The log stack trace.70*/71get stackTrace() {72return this._stackTrace73}7475get source() {76return this._source77}78}7980/**81* Represents a generic log entry.82* @class83* @extends BaseLogEntry84*/85class GenericLogEntry extends BaseLogEntry {86/**87* Creates an instance of GenericLogEntry.88* @param {string} level - The log level.89* @param {source} source - Script Source90* @param {string} text - The log text.91* @param {Date} timeStamp - The log timestamp.92* @param {string} type - The log type.93* @param {string} stackTrace - The log stack trace.94*/95constructor(level, source, text, timeStamp, type, stackTrace) {96super(level, source, text, timeStamp, stackTrace)97this._type = type98}99100/**101* Gets the log type.102* @returns {string} The log type.103*/104get type() {105return this._type106}107}108109/**110* Represents a log entry for console logs.111* @class112* @extends GenericLogEntry113*/114class ConsoleLogEntry extends GenericLogEntry {115constructor(level, source, text, timeStamp, type, method, args, stackTrace) {116super(level, source, text, timeStamp, type, stackTrace)117this._method = method118this._args = args119}120121/**122* Gets the method associated with the log entry.123* @returns {string} The method associated with the log entry.124*/125get method() {126return this._method127}128/**129* Gets the arguments associated with the log entry.130* @returns {Array} The arguments associated with the log entry.131*/132get args() {133return this._args134}135}136137/**138* Represents a log entry for JavaScript logs.139* @class140* @extends GenericLogEntry141*/142class JavascriptLogEntry extends GenericLogEntry {143constructor(level, source, text, timeStamp, type, stackTrace) {144super(level, source, text, timeStamp, type, stackTrace)145}146}147148// PUBLIC API149150module.exports = {151BaseLogEntry,152GenericLogEntry,153ConsoleLogEntry,154JavascriptLogEntry,155}156157158