appium-xcuitest-driver 7.21.1 → 7.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +6 -3
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +30 -16
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/device-log/helpers.d.ts +4 -1
- package/build/lib/device-log/helpers.d.ts.map +1 -1
- package/build/lib/device-log/helpers.js +6 -2
- package/build/lib/device-log/helpers.js.map +1 -1
- package/build/lib/device-log/ios-crash-log.d.ts +0 -4
- package/build/lib/device-log/ios-crash-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-crash-log.js +0 -8
- package/build/lib/device-log/ios-crash-log.js.map +1 -1
- package/build/lib/device-log/ios-device-log.d.ts +16 -10
- package/build/lib/device-log/ios-device-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-device-log.js +9 -24
- package/build/lib/device-log/ios-device-log.js.map +1 -1
- package/build/lib/device-log/ios-log.d.ts +21 -44
- package/build/lib/device-log/ios-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-log.js +16 -77
- package/build/lib/device-log/ios-log.js.map +1 -1
- package/build/lib/device-log/ios-performance-log.d.ts +14 -26
- package/build/lib/device-log/ios-performance-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-performance-log.js +16 -42
- package/build/lib/device-log/ios-performance-log.js.map +1 -1
- package/build/lib/device-log/ios-simulator-log.d.ts +21 -24
- package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-simulator-log.js +18 -36
- package/build/lib/device-log/ios-simulator-log.js.map +1 -1
- package/build/lib/device-log/line-consuming-log.d.ts +9 -0
- package/build/lib/device-log/line-consuming-log.d.ts.map +1 -0
- package/build/lib/device-log/line-consuming-log.js +16 -0
- package/build/lib/device-log/line-consuming-log.js.map +1 -0
- package/build/lib/device-log/safari-console-log.d.ts +65 -6
- package/build/lib/device-log/safari-console-log.d.ts.map +1 -1
- package/build/lib/device-log/safari-console-log.js +61 -81
- package/build/lib/device-log/safari-console-log.js.map +1 -1
- package/build/lib/device-log/safari-network-log.d.ts +36 -8
- package/build/lib/device-log/safari-network-log.d.ts.map +1 -1
- package/build/lib/device-log/safari-network-log.js +28 -151
- package/build/lib/device-log/safari-network-log.js.map +1 -1
- package/lib/commands/context.js +6 -3
- package/lib/commands/log.js +35 -16
- package/lib/device-log/helpers.ts +6 -2
- package/lib/device-log/ios-crash-log.js +0 -9
- package/lib/device-log/ios-device-log.ts +52 -0
- package/lib/device-log/ios-log.ts +70 -0
- package/lib/device-log/ios-performance-log.ts +50 -0
- package/lib/device-log/{ios-simulator-log.js → ios-simulator-log.ts} +40 -43
- package/lib/device-log/line-consuming-log.ts +16 -0
- package/lib/device-log/safari-console-log.ts +112 -0
- package/lib/device-log/safari-network-log.ts +80 -0
- package/npm-shrinkwrap.json +69 -24
- package/package.json +2 -2
- package/build/lib/device-log/rotating-log.d.ts +0 -21
- package/build/lib/device-log/rotating-log.d.ts.map +0 -1
- package/build/lib/device-log/rotating-log.js +0 -61
- package/build/lib/device-log/rotating-log.js.map +0 -1
- package/lib/device-log/ios-device-log.js +0 -56
- package/lib/device-log/ios-log.js +0 -116
- package/lib/device-log/ios-performance-log.js +0 -68
- package/lib/device-log/rotating-log.js +0 -65
- package/lib/device-log/safari-console-log.js +0 -96
- package/lib/device-log/safari-network-log.js +0 -193
|
@@ -4,93 +4,73 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SafariConsoleLog = void 0;
|
|
7
|
-
const rotating_log_1 = require("./rotating-log");
|
|
8
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
9
|
+
const ios_log_1 = __importDefault(require("./ios-log"));
|
|
10
|
+
const LOG_LEVELS_MAP = {
|
|
11
|
+
error: 'SEVERE',
|
|
12
|
+
warning: 'WARNING',
|
|
13
|
+
log: 'FINE',
|
|
14
|
+
};
|
|
15
|
+
class SafariConsoleLog extends ios_log_1.default {
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
super({
|
|
18
|
+
log: opts.log,
|
|
19
|
+
maxBufferSize: helpers_1.MAX_BUFFERED_EVENTS_COUNT,
|
|
18
20
|
});
|
|
21
|
+
this._showLogs = opts.showLogs;
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
warning: 'WARNING',
|
|
59
|
-
log: 'FINE',
|
|
60
|
-
}[out.level] || 'INFO',
|
|
61
|
-
timestamp: Date.now(),
|
|
62
|
-
message: JSON.stringify(out),
|
|
63
|
-
};
|
|
64
|
-
this.logs.push(entry);
|
|
65
|
-
}
|
|
66
|
-
if (lodash_1.default.has(out, 'count')) {
|
|
67
|
-
// this is a notification of the previous message being repeated
|
|
68
|
-
// this should _never_ be the first message, so the previous one ought to
|
|
69
|
-
// be populated. If it is not, nothing will break, it will just look odd
|
|
70
|
-
// in the output below (no url or line numbers)
|
|
71
|
-
const count = out.count;
|
|
72
|
-
out = this._previousOutput || {};
|
|
73
|
-
out.text = `Previous message repeated ${support_1.util.pluralize('time', count, true)}`;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// save the most recent output
|
|
77
|
-
this._previousOutput = out;
|
|
78
|
-
}
|
|
79
|
-
// format output like
|
|
80
|
-
// SafariConsole [WARNING][http://appium.io 2:13] Log something to warn
|
|
81
|
-
if (this.showLogs) {
|
|
82
|
-
let level = 'debug';
|
|
83
|
-
if (out.level === 'warning' || out.level === 'error') {
|
|
84
|
-
level = out.level;
|
|
85
|
-
}
|
|
86
|
-
for (const line of out.text.split('\n')) {
|
|
87
|
-
// url is optional, so get formatting here
|
|
88
|
-
const url = out.url ? `${out.url} ` : '';
|
|
89
|
-
this.log[level](`[${level.toUpperCase()}][${url}${out.line}:${out.column}] ${line}`);
|
|
90
|
-
}
|
|
23
|
+
async startCapture() { }
|
|
24
|
+
async stopCapture() { }
|
|
25
|
+
get isCapturing() {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param err
|
|
31
|
+
* @param entry The output will be like:
|
|
32
|
+
* {
|
|
33
|
+
* "source": "javascript",
|
|
34
|
+
* "level":"error",
|
|
35
|
+
* "text":"ReferenceError: Can't find variable: s_account",
|
|
36
|
+
* "type":"log",
|
|
37
|
+
* "line":2,
|
|
38
|
+
* "column":21,
|
|
39
|
+
* "url":"https://assets.adobedtm.com/b46e318d845250834eda10c5a20827c045a4d76f/scripts/satellite-57866f8b64746d53a8000104-staging.js",
|
|
40
|
+
* "repeatCount":1,
|
|
41
|
+
* "stackTrace":[{
|
|
42
|
+
* "functionName":"global code",
|
|
43
|
+
* "url":"https://assets.adobedtm.com/b46e318d845250834eda10c5a20827c045a4d76f/scripts/satellite-57866f8b64746d53a8000104-staging.js",
|
|
44
|
+
* "scriptId":"6",
|
|
45
|
+
* "lineNumber":2,
|
|
46
|
+
* "columnNumber":21
|
|
47
|
+
* }]
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* we need, at least, `level` (in accordance with Java levels
|
|
51
|
+
* (https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html)),
|
|
52
|
+
* `timestamp`, and `message` to satisfy the java client. In order to
|
|
53
|
+
* provide all the information to the client, `message` is the full
|
|
54
|
+
* object, stringified.
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
onConsoleLogEvent(err, entry) {
|
|
58
|
+
this.broadcast(entry);
|
|
59
|
+
if (this._showLogs) {
|
|
60
|
+
this.log.info(`[SafariConsole] ${lodash_1.default.truncate(JSON.stringify(entry), { length: helpers_1.MAX_JSON_LOG_LENGTH })}`);
|
|
91
61
|
}
|
|
92
62
|
}
|
|
63
|
+
_serializeEntry(value) {
|
|
64
|
+
return [value, Date.now()];
|
|
65
|
+
}
|
|
66
|
+
_deserializeEntry(value) {
|
|
67
|
+
const [entry, timestamp] = value;
|
|
68
|
+
return (0, helpers_1.toLogEntry)(JSON.stringify(entry), timestamp, mapLogLevel(entry.level));
|
|
69
|
+
}
|
|
93
70
|
}
|
|
94
71
|
exports.SafariConsoleLog = SafariConsoleLog;
|
|
72
|
+
function mapLogLevel(originalLevel) {
|
|
73
|
+
return LOG_LEVELS_MAP[originalLevel] ?? helpers_1.DEFAULT_LOG_LEVEL;
|
|
74
|
+
}
|
|
95
75
|
exports.default = SafariConsoleLog;
|
|
96
76
|
//# sourceMappingURL=safari-console-log.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safari-console-log.js","sourceRoot":"","sources":["../../../lib/device-log/safari-console-log.
|
|
1
|
+
{"version":3,"file":"safari-console-log.js","sourceRoot":"","sources":["../../../lib/device-log/safari-console-log.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,uCAKmB;AACnB,wDAA+B;AAG/B,MAAM,cAAc,GAAG;IACrB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,MAAM;CACZ,CAAC;AA6BF,MAAa,gBAAiB,SAAQ,iBAA4C;IAGhF,YAAY,IAA6B;QACvC,KAAK,CAAC;YACJ,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,aAAa,EAAE,mCAAyB;SACzC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;IACjC,CAAC;IAEQ,KAAK,CAAC,YAAY,KAAmB,CAAC;IACtC,KAAK,CAAC,WAAW,KAAmB,CAAC;IAC9C,IAAa,WAAW;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,iBAAiB,CAAC,GAAkB,EAAE,KAAyB;QAC7D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,gBAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAC,MAAM,EAAE,6BAAmB,EAAC,CAAC,EAAE,CAAC,CAAC;QACvG,CAAC;IACH,CAAC;IAEkB,eAAe,CAAC,KAAyB;QAC1D,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,CAAC;IAEkB,iBAAiB,CAAC,KAAuB;QAC1D,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;QACjC,OAAO,IAAA,oBAAU,EAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChF,CAAC;CACF;AA7DD,4CA6DC;AAED,SAAS,WAAW,CAAC,aAAqB;IACxC,OAAO,cAAc,CAAC,aAAa,CAAC,IAAI,2BAAiB,CAAC;AAC5D,CAAC;AAED,kBAAe,gBAAgB,CAAC"}
|
|
@@ -1,10 +1,38 @@
|
|
|
1
|
+
import { LineConsumingLog } from './line-consuming-log';
|
|
2
|
+
import type { AppiumLogger } from '@appium/types';
|
|
3
|
+
export interface SafariConsoleLogOptions {
|
|
4
|
+
showLogs: boolean;
|
|
5
|
+
log: AppiumLogger;
|
|
6
|
+
}
|
|
7
|
+
export interface SafariNetworkResponseTiming {
|
|
8
|
+
responseStart: number;
|
|
9
|
+
receiveHeadersEnd: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SafariNetworkResponse {
|
|
12
|
+
url: string;
|
|
13
|
+
status: number;
|
|
14
|
+
timing: SafariNetworkResponseTiming;
|
|
15
|
+
source: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SafariNetworkLogEntryMetrics {
|
|
18
|
+
responseBodyBytesReceived: number;
|
|
19
|
+
}
|
|
20
|
+
export interface SafariNetworkLogEntry {
|
|
21
|
+
requestId: string;
|
|
22
|
+
response?: SafariNetworkResponse;
|
|
23
|
+
type?: string;
|
|
24
|
+
initiator?: string;
|
|
25
|
+
metrics?: SafariNetworkLogEntryMetrics;
|
|
26
|
+
errorText?: string;
|
|
27
|
+
canceled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare class SafariNetworkLog extends LineConsumingLog {
|
|
30
|
+
private readonly _showLogs;
|
|
31
|
+
constructor(opts: SafariConsoleLogOptions);
|
|
32
|
+
startCapture(): Promise<void>;
|
|
33
|
+
stopCapture(): Promise<void>;
|
|
34
|
+
get isCapturing(): boolean;
|
|
35
|
+
onNetworkEvent(method: string, entry: SafariNetworkLogEntry): void;
|
|
36
|
+
}
|
|
1
37
|
export default SafariNetworkLog;
|
|
2
|
-
export class SafariNetworkLog extends RotatingLog {
|
|
3
|
-
constructor(showLogs: any);
|
|
4
|
-
getEntry(requestId: any): any;
|
|
5
|
-
addLogLine(method: any, out: any): void;
|
|
6
|
-
getLogDetails(outputEntry: any): any;
|
|
7
|
-
printLogLine(outputEntry: any): void;
|
|
8
|
-
}
|
|
9
|
-
import { RotatingLog } from './rotating-log';
|
|
10
38
|
//# sourceMappingURL=safari-network-log.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safari-network-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/safari-network-log.
|
|
1
|
+
{"version":3,"file":"safari-network-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/safari-network-log.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAYlD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,YAAY,CAAC;CACnB;AAED,MAAM,WAAW,2BAA2B;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,2BAA2B,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,yBAAyB,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,4BAA4B,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,gBAAiB,SAAQ,gBAAgB;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;gBAExB,IAAI,EAAE,uBAAuB;IAQ1B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAC7B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAC3C,IAAa,WAAW,IAAI,OAAO,CAElC;IAED,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,IAAI;CAWnE;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -5,163 +5,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SafariNetworkLog = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const line_consuming_log_1 = require("./line-consuming-log");
|
|
9
|
+
const helpers_1 = require("./helpers");
|
|
10
|
+
const EVENTS_TO_LOG = [
|
|
11
|
+
'Network.loadingFinished',
|
|
12
|
+
'Network.loadingFailed',
|
|
13
|
+
];
|
|
14
|
+
const MONITORED_EVENTS = [
|
|
15
|
+
'Network.requestWillBeSent',
|
|
16
|
+
'Network.responseReceived',
|
|
17
|
+
...EVENTS_TO_LOG,
|
|
18
|
+
];
|
|
19
|
+
class SafariNetworkLog extends line_consuming_log_1.LineConsumingLog {
|
|
20
|
+
constructor(opts) {
|
|
21
|
+
super({
|
|
22
|
+
log: opts.log,
|
|
23
|
+
maxBufferSize: helpers_1.MAX_BUFFERED_EVENTS_COUNT,
|
|
24
|
+
});
|
|
25
|
+
this._showLogs = opts.showLogs;
|
|
14
26
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const entry = this.logs.shift();
|
|
20
|
-
if (entry && entry.requestId === requestId) {
|
|
21
|
-
// we are adding to an existing entry, and it was almost removed
|
|
22
|
-
// add to the end of the list and try again
|
|
23
|
-
outputEntry = entry;
|
|
24
|
-
this.logs.push(outputEntry);
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
// we've removed an element, so the count is down one
|
|
28
|
-
if (this.logIdxSinceLastRequest > 0) {
|
|
29
|
-
this.logIdxSinceLastRequest--;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (!outputEntry) {
|
|
33
|
-
// we do not yes have an entry to associate this bit of output with
|
|
34
|
-
// most likely the entry will be at the end of the list, so start there
|
|
35
|
-
for (let i = this.logs.length - 1; i >= 0; i--) {
|
|
36
|
-
if (this.logs[i].requestId === requestId) {
|
|
37
|
-
// found it!
|
|
38
|
-
outputEntry = this.logs[i];
|
|
39
|
-
// this is now the most current entry, so remove it from the list
|
|
40
|
-
// to be added to the end below
|
|
41
|
-
this.logs.splice(i, 1);
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// nothing has been found, so create a new entry
|
|
46
|
-
if (!outputEntry) {
|
|
47
|
-
outputEntry = {
|
|
48
|
-
requestId,
|
|
49
|
-
logs: [],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
// finally, add the entry to the end of the list
|
|
53
|
-
this.logs.push(outputEntry);
|
|
54
|
-
}
|
|
55
|
-
return outputEntry;
|
|
27
|
+
async startCapture() { }
|
|
28
|
+
async stopCapture() { }
|
|
29
|
+
get isCapturing() {
|
|
30
|
+
return true;
|
|
56
31
|
}
|
|
57
|
-
|
|
58
|
-
if (!
|
|
59
|
-
// neither capturing nor displaying, so do nothing
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (['Network.dataReceived'].includes(method)) {
|
|
63
|
-
// status update, no need to handle
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
// events we care about:
|
|
67
|
-
// Network.requestWillBeSent
|
|
68
|
-
// Network.responseReceived
|
|
69
|
-
// Network.loadingFinished
|
|
70
|
-
// Network.loadingFailed
|
|
71
|
-
const outputEntry = this.getEntry(out.requestId);
|
|
72
|
-
if (this.isCapturing) {
|
|
73
|
-
// now add the output we just received to the logs for this particular entry
|
|
74
|
-
outputEntry.logs = outputEntry.logs || [];
|
|
75
|
-
outputEntry.logs.push(out);
|
|
76
|
-
}
|
|
77
|
-
// if we are not displaying the logs,
|
|
78
|
-
// or we are not finished getting events for this network call,
|
|
79
|
-
// we are done
|
|
80
|
-
if (!this.showLogs) {
|
|
32
|
+
onNetworkEvent(method, entry) {
|
|
33
|
+
if (!MONITORED_EVENTS.includes(method)) {
|
|
81
34
|
return;
|
|
82
35
|
}
|
|
83
|
-
|
|
84
|
-
|
|
36
|
+
const serializedEntry = JSON.stringify(entry);
|
|
37
|
+
this.broadcast(serializedEntry);
|
|
38
|
+
if (this._showLogs && EVENTS_TO_LOG.includes(method)) {
|
|
39
|
+
this.log.info(`[SafariNetwork] ${lodash_1.default.truncate(serializedEntry, { length: helpers_1.MAX_JSON_LOG_LENGTH })}`);
|
|
85
40
|
}
|
|
86
41
|
}
|
|
87
|
-
getLogDetails(outputEntry) {
|
|
88
|
-
// extract the data
|
|
89
|
-
const record = outputEntry.logs.reduce(function getRecord(record, entry) {
|
|
90
|
-
record.requestId = entry.requestId;
|
|
91
|
-
if (entry.response) {
|
|
92
|
-
const url = url_1.default.parse(entry.response.url);
|
|
93
|
-
// get the last part of the url, along with the query string, if possible
|
|
94
|
-
record.name =
|
|
95
|
-
`${lodash_1.default.last(String(url.pathname).split('/'))}${url.search ? `?${url.search}` : ''}` ||
|
|
96
|
-
url.host;
|
|
97
|
-
record.status = entry.response.status;
|
|
98
|
-
if (entry.response.timing) {
|
|
99
|
-
record.time =
|
|
100
|
-
entry.response.timing.receiveHeadersEnd || entry.response.timing.responseStart || 0;
|
|
101
|
-
}
|
|
102
|
-
record.source = entry.response.source;
|
|
103
|
-
}
|
|
104
|
-
if (entry.type) {
|
|
105
|
-
record.type = entry.type;
|
|
106
|
-
}
|
|
107
|
-
if (entry.initiator) {
|
|
108
|
-
record.initiator = entry.initiator;
|
|
109
|
-
}
|
|
110
|
-
if (entry.metrics) {
|
|
111
|
-
// Safari has a `metrics` object on it's `Network.loadingFinished` event
|
|
112
|
-
record.size = entry.metrics.responseBodyBytesReceived || 0;
|
|
113
|
-
}
|
|
114
|
-
if (entry.errorText) {
|
|
115
|
-
record.errorText = entry.errorText;
|
|
116
|
-
// When a network call is cancelled, Safari returns `cancelled` as error text
|
|
117
|
-
// but has a boolean `canceled`. Normalize the two spellings in favor of
|
|
118
|
-
// the text, which will also be displayed
|
|
119
|
-
record.cancelled = entry.canceled;
|
|
120
|
-
}
|
|
121
|
-
return record;
|
|
122
|
-
}, {});
|
|
123
|
-
return record;
|
|
124
|
-
}
|
|
125
|
-
printLogLine(outputEntry) {
|
|
126
|
-
const { requestId, name, status, type, initiator = {}, size = 0, time = 0, source, errorText, cancelled = false, } = this.getLogDetails(outputEntry);
|
|
127
|
-
// print out the record, formatted appropriately
|
|
128
|
-
this.log.debug(`Network event:`);
|
|
129
|
-
this.log.debug(` Id: ${requestId}`);
|
|
130
|
-
this.log.debug(` Name: ${name}`);
|
|
131
|
-
this.log.debug(` Status: ${status}`);
|
|
132
|
-
this.log.debug(` Type: ${type}`);
|
|
133
|
-
this.log.debug(` Initiator: ${initiator.type}`);
|
|
134
|
-
for (const line of initiator.stackTrace || []) {
|
|
135
|
-
const functionName = line.functionName || '(anonymous)';
|
|
136
|
-
const url = !line.url || line.url === '[native code]'
|
|
137
|
-
? ''
|
|
138
|
-
: `@${lodash_1.default.last((url_1.default.parse(line.url).pathname || '').split('/'))}:${line.lineNumber}`;
|
|
139
|
-
this.log.debug(` ${lodash_1.default.padEnd(lodash_1.default.truncate(functionName, { length: 20 }), 21)} ${url}`);
|
|
140
|
-
}
|
|
141
|
-
// get `memory-cache` or `disk-cache`, etc., right
|
|
142
|
-
const sizeStr = source.includes('cache') ? ` (from ${source.replace('-', ' ')})` : `${size}B`;
|
|
143
|
-
this.log.debug(` Size: ${sizeStr}`);
|
|
144
|
-
this.log.debug(` Time: ${Math.round(time)}ms`);
|
|
145
|
-
if (errorText) {
|
|
146
|
-
this.log.debug(` Error: ${errorText}`);
|
|
147
|
-
}
|
|
148
|
-
if (support_1.util.hasValue(cancelled)) {
|
|
149
|
-
this.log.debug(` Cancelled: ${cancelled}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async getLogs() {
|
|
153
|
-
const logs = await super.getLogs();
|
|
154
|
-
// in order to satisfy certain clients, we need to have a basic structure
|
|
155
|
-
// to the results, with `level`, `timestamp`, and `message`, which is
|
|
156
|
-
// all the information stringified
|
|
157
|
-
return logs.map(function adjustEntry(entry) {
|
|
158
|
-
return Object.assign({}, entry, {
|
|
159
|
-
level: 'INFO',
|
|
160
|
-
timestamp: Date.now(),
|
|
161
|
-
message: JSON.stringify(entry),
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
42
|
}
|
|
166
43
|
exports.SafariNetworkLog = SafariNetworkLog;
|
|
167
44
|
exports.default = SafariNetworkLog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safari-network-log.js","sourceRoot":"","sources":["../../../lib/device-log/safari-network-log.
|
|
1
|
+
{"version":3,"file":"safari-network-log.js","sourceRoot":"","sources":["../../../lib/device-log/safari-network-log.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,6DAAwD;AACxD,uCAA2E;AAG3E,MAAM,aAAa,GAAG;IACpB,yBAAyB;IACzB,uBAAuB;CACxB,CAAC;AACF,MAAM,gBAAgB,GAAG;IACvB,2BAA2B;IAC3B,0BAA0B;IAC1B,GAAG,aAAa;CACjB,CAAC;AAoCF,MAAa,gBAAiB,SAAQ,qCAAgB;IAGpD,YAAY,IAA6B;QACvC,KAAK,CAAC;YACJ,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,aAAa,EAAE,mCAAyB;SACzC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;IACjC,CAAC;IAEQ,KAAK,CAAC,YAAY,KAAmB,CAAC;IACtC,KAAK,CAAC,WAAW,KAAmB,CAAC;IAC9C,IAAa,WAAW;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,KAA4B;QACzD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QAED,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,SAAS,IAAI,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,gBAAC,CAAC,QAAQ,CAAC,eAAe,EAAE,EAAC,MAAM,EAAE,6BAAmB,EAAC,CAAC,EAAE,CAAC,CAAC;QACjG,CAAC;IACH,CAAC;CACF;AA5BD,4CA4BC;AAED,kBAAe,gBAAgB,CAAC"}
|
package/lib/commands/context.js
CHANGED
|
@@ -558,7 +558,10 @@ const commands = {
|
|
|
558
558
|
// attempt to start performance logging, if requested
|
|
559
559
|
if (this.opts.enablePerformanceLogging && this.remote) {
|
|
560
560
|
this.log.debug(`Starting performance log on '${this.curContext}'`);
|
|
561
|
-
this.logs.performance = new IOSPerformanceLog(
|
|
561
|
+
this.logs.performance = new IOSPerformanceLog({
|
|
562
|
+
remoteDebugger: this.remote,
|
|
563
|
+
log: this.log,
|
|
564
|
+
});
|
|
562
565
|
await this.logs.performance.startCapture();
|
|
563
566
|
}
|
|
564
567
|
|
|
@@ -566,12 +569,12 @@ const commands = {
|
|
|
566
569
|
if (name && name !== NATIVE_WIN && this.logs) {
|
|
567
570
|
if (this.logs.safariConsole) {
|
|
568
571
|
await this.remote.startConsole(
|
|
569
|
-
this.logs.safariConsole.
|
|
572
|
+
this.logs.safariConsole.onConsoleLogEvent.bind(this.logs.safariConsole),
|
|
570
573
|
);
|
|
571
574
|
}
|
|
572
575
|
if (this.logs.safariNetwork) {
|
|
573
576
|
await this.remote.startNetwork(
|
|
574
|
-
this.logs.safariNetwork.
|
|
577
|
+
this.logs.safariNetwork.onNetworkEvent.bind(this.logs.safariNetwork),
|
|
575
578
|
);
|
|
576
579
|
}
|
|
577
580
|
}
|
package/lib/commands/log.js
CHANGED
|
@@ -60,6 +60,12 @@ const SUPPORTED_LOG_TYPES = {
|
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
const LOG_NAMES_TO_CAPABILITY_NAMES_MAP = {
|
|
64
|
+
safariConsole: 'showSafariConsoleLog',
|
|
65
|
+
safariNetwork: 'showSafariNetworkLog',
|
|
66
|
+
enablePerformanceLogging: 'enablePerformanceLogging',
|
|
67
|
+
};
|
|
68
|
+
|
|
63
69
|
export default {
|
|
64
70
|
supportedLogTypes: SUPPORTED_LOG_TYPES,
|
|
65
71
|
/**
|
|
@@ -77,11 +83,18 @@ export default {
|
|
|
77
83
|
|
|
78
84
|
// If logs captured successfully send response with data, else send error
|
|
79
85
|
const logObject = logsContainer[logType];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
if (logObject) {
|
|
87
|
+
return await logObject.getLogs();
|
|
88
|
+
}
|
|
89
|
+
if (logType in LOG_NAMES_TO_CAPABILITY_NAMES_MAP) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`${logType} logs are not enabled. Make sure you've set a proper value ` +
|
|
92
|
+
`to the 'appium:${LOG_NAMES_TO_CAPABILITY_NAMES_MAP[logType]}' capability.`
|
|
93
|
+
);
|
|
83
94
|
}
|
|
84
|
-
throw new Error(
|
|
95
|
+
throw new Error(
|
|
96
|
+
`No logs of type '${logType}' found. Supported log types are: ${_.keys(SUPPORTED_LOG_TYPES)}.`
|
|
97
|
+
);
|
|
85
98
|
},
|
|
86
99
|
|
|
87
100
|
/**
|
|
@@ -98,22 +111,30 @@ export default {
|
|
|
98
111
|
sim: this.device,
|
|
99
112
|
udid: this.isRealDevice() ? this.opts.udid : undefined,
|
|
100
113
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.logs.syslog = new IOSDeviceLog({
|
|
114
|
+
this.logs.syslog = this.isRealDevice()
|
|
115
|
+
? new IOSDeviceLog({
|
|
104
116
|
udid: this.opts.udid,
|
|
105
117
|
showLogs: this.opts.showIOSLog,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
sim: this.device,
|
|
118
|
+
log: this.log,
|
|
119
|
+
})
|
|
120
|
+
: new IOSSimulatorLog({
|
|
121
|
+
sim: /** @type {import('appium-ios-simulator').Simulator} */ (this.device),
|
|
110
122
|
showLogs: this.opts.showIOSLog,
|
|
111
|
-
xcodeVersion: this.xcodeVersion,
|
|
112
123
|
iosSimulatorLogsPredicate: this.opts.iosSimulatorLogsPredicate,
|
|
124
|
+
log: this.log,
|
|
125
|
+
});
|
|
126
|
+
if (_.isBoolean(this.opts.showSafariConsoleLog)) {
|
|
127
|
+
this.logs.safariConsole = new SafariConsoleLog({
|
|
128
|
+
showLogs: this.opts.showSafariConsoleLog,
|
|
129
|
+
log: this.log,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (_.isBoolean(this.opts.showSafariNetworkLog)) {
|
|
133
|
+
this.logs.safariNetwork = new SafariNetworkLog({
|
|
134
|
+
showLogs: this.opts.showSafariNetworkLog,
|
|
135
|
+
log: this.log,
|
|
113
136
|
});
|
|
114
137
|
}
|
|
115
|
-
this.logs.safariConsole = new SafariConsoleLog(!!this.opts.showSafariConsoleLog);
|
|
116
|
-
this.logs.safariNetwork = new SafariNetworkLog(!!this.opts.showSafariNetworkLog);
|
|
117
138
|
}
|
|
118
139
|
|
|
119
140
|
let didStartSyslog = false;
|
|
@@ -129,8 +150,6 @@ export default {
|
|
|
129
150
|
}
|
|
130
151
|
})(),
|
|
131
152
|
this.logs.crashlog.startCapture(),
|
|
132
|
-
this.logs.safariConsole.startCapture(),
|
|
133
|
-
this.logs.safariNetwork.startCapture(),
|
|
134
153
|
];
|
|
135
154
|
await B.all(promises);
|
|
136
155
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { LogEntry } from '../commands/types';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const DEFAULT_LOG_LEVEL = 'ALL';
|
|
4
|
+
export const MAX_JSON_LOG_LENGTH = 200;
|
|
5
|
+
export const MAX_BUFFERED_EVENTS_COUNT = 5000;
|
|
6
|
+
|
|
7
|
+
export function toLogEntry(message: string, timestamp: number, level: string = DEFAULT_LOG_LEVEL): LogEntry {
|
|
4
8
|
return {
|
|
5
9
|
timestamp,
|
|
6
|
-
level
|
|
10
|
+
level,
|
|
7
11
|
message,
|
|
8
12
|
};
|
|
9
13
|
}
|
|
@@ -105,15 +105,6 @@ class IOSCrashLog {
|
|
|
105
105
|
return await this.filesToJSON(diff);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/**
|
|
109
|
-
* @returns {Promise<import('../commands/types').LogEntry[]>}
|
|
110
|
-
*/
|
|
111
|
-
async getAllLogs() {
|
|
112
|
-
let crashFiles = await this.getCrashes();
|
|
113
|
-
let logFiles = _.difference(crashFiles, this.prevLogs);
|
|
114
|
-
return await this.filesToJSON(logFiles);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
108
|
/**
|
|
118
109
|
* @param {string[]} paths
|
|
119
110
|
* @returns {Promise<import('../commands/types').LogEntry[]>}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {services} from 'appium-ios-device';
|
|
2
|
+
import { LineConsumingLog } from './line-consuming-log';
|
|
3
|
+
import type { AppiumLogger } from '@appium/types';
|
|
4
|
+
|
|
5
|
+
export interface IOSDeviceLogOpts {
|
|
6
|
+
udid: string;
|
|
7
|
+
showLogs?: boolean;
|
|
8
|
+
log: AppiumLogger;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class IOSDeviceLog extends LineConsumingLog {
|
|
12
|
+
private readonly udid: string;
|
|
13
|
+
private readonly showLogs: boolean;
|
|
14
|
+
private service: any | null;
|
|
15
|
+
|
|
16
|
+
constructor(opts: IOSDeviceLogOpts) {
|
|
17
|
+
super({log: opts.log});
|
|
18
|
+
this.udid = opts.udid;
|
|
19
|
+
this.showLogs = !!opts.showLogs;
|
|
20
|
+
this.service = null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override async startCapture(): Promise<void> {
|
|
24
|
+
if (this.service) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.service = await services.startSyslogService(this.udid);
|
|
28
|
+
this.service.start(this.onLog.bind(this));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override get isCapturing(): boolean {
|
|
32
|
+
return !!this.service;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line require-await
|
|
36
|
+
override async stopCapture(): Promise<void> {
|
|
37
|
+
if (!this.service) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.service.close();
|
|
41
|
+
this.service = null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private onLog(logLine: string): void {
|
|
45
|
+
this.broadcast(logLine);
|
|
46
|
+
if (this.showLogs) {
|
|
47
|
+
this.log.info(`[IOS_SYSLOG_ROW] ${logLine}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default IOSDeviceLog;
|