UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

76 lines 2.7 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SafariConsoleLog = void 0; const lodash_1 = __importDefault(require("lodash")); const helpers_1 = require("./helpers"); const ios_log_1 = require("./ios-log"); const LOG_LEVELS_MAP = { error: 'SEVERE', warning: 'WARNING', log: 'FINE', }; class SafariConsoleLog extends ios_log_1.IOSLog { constructor(opts) { super({ log: opts.log, maxBufferSize: helpers_1.MAX_BUFFERED_EVENTS_COUNT, }); this._showLogs = opts.showLogs; } async startCapture() { } async stopCapture() { } get isCapturing() { return true; } /** * * @param err * @param entry The output will be like: * { * "source": "javascript", * "level":"error", * "text":"ReferenceError: Can't find variable: s_account", * "type":"log", * "line":2, * "column":21, * "url":"https://assets.adobedtm.com/b46e318d845250834eda10c5a20827c045a4d76f/scripts/satellite-57866f8b64746d53a8000104-staging.js", * "repeatCount":1, * "stackTrace":[{ * "functionName":"global code", * "url":"https://assets.adobedtm.com/b46e318d845250834eda10c5a20827c045a4d76f/scripts/satellite-57866f8b64746d53a8000104-staging.js", * "scriptId":"6", * "lineNumber":2, * "columnNumber":21 * }] * } * * we need, at least, `level` (in accordance with Java levels * (https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html)), * `timestamp`, and `message` to satisfy the java client. In order to * provide all the information to the client, `message` is the full * object, stringified. * */ onConsoleLogEvent(err, entry) { this.broadcast(entry); if (this._showLogs) { this.log.info(`[SafariConsole] ${lodash_1.default.truncate(JSON.stringify(entry), { length: helpers_1.MAX_JSON_LOG_LENGTH })}`); } } _serializeEntry(value) { return [value, Date.now()]; } _deserializeEntry(value) { const [entry, timestamp] = value; return (0, helpers_1.toLogEntry)(JSON.stringify(entry), timestamp, mapLogLevel(entry.level)); } } exports.SafariConsoleLog = SafariConsoleLog; function mapLogLevel(originalLevel) { return LOG_LEVELS_MAP[originalLevel] ?? helpers_1.DEFAULT_LOG_LEVEL; } exports.default = SafariConsoleLog; //# sourceMappingURL=safari-console-log.js.map