Skip to content

Commit 42ea673

Browse files
Merge pull request #79 from telerik/vladimirov/simulator-logs
Return simulator log to caller and do not filter the output
2 parents 1491913 + 8004bac commit 42ea673

8 files changed

+26
-3
lines changed

lib/declarations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ interface ISimulator extends INameGetter {
5656
startApplication(deviceId: string, appIdentifier: string): IFuture<string>;
5757
stopApplication(deviceId: string, appIdentifier: string): IFuture<string>;
5858
printDeviceLog(deviceId: string, launchResult?: string): any;
59+
getDeviceLogProcess(deviceId: string): any;
5960
startSimulator(): IFuture<void>;
6061
}
6162

lib/ios-sim.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Object.defineProperty(global.publicApi, "getInstalledApplications", {
7272
"startApplication",
7373
"stopApplication",
7474
"printDeviceLog",
75+
"getDeviceLogProcess",
7576
"startSimulator",
7677
"getSimulatorName"].forEach(methodName => {
7778
Object.defineProperty(global.publicApi, methodName, {

lib/iphone-simulator-common.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ export function printDeviceLog(deviceId: string, launchResult?: string): any {
4848
}
4949

5050
if (!isDeviceLogOperationStarted) {
51-
let logFilePath = path.join(osenv.home(), "Library", "Logs", "CoreSimulator", deviceId, "system.log");
52-
deviceLogChildProcess = require("child_process").spawn("tail", ['-f', '-n', '1', logFilePath]);
51+
deviceLogChildProcess = this.getDeviceLogProcess(deviceId);
5352
if (deviceLogChildProcess.stdout) {
5453
deviceLogChildProcess.stdout.on("data", (data: NodeBuffer) => {
5554
let dataAsString = data.toString();
@@ -76,7 +75,15 @@ export function printDeviceLog(deviceId: string, launchResult?: string): any {
7675
process.stdout.write(data.toString());
7776
});
7877
}
78+
}
7979

80+
return deviceLogChildProcess;
81+
}
82+
83+
export function getDeviceLogProcess(deviceId: string): any {
84+
if (!isDeviceLogOperationStarted) {
85+
let logFilePath = path.join(osenv.home(), "Library", "Logs", "CoreSimulator", deviceId, "system.log");
86+
deviceLogChildProcess = require("child_process").spawn("tail", ['-f', '-n', '1', logFilePath]);
8087
isDeviceLogOperationStarted = true;
8188
}
8289

lib/iphone-simulator-xcode-5.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export class XCode5Simulator extends iPhoneSimulatorBaseLib.IPhoneInteropSimulat
8686

8787
public printDeviceLog(deviceId: string): any { }
8888

89+
public getDeviceLogProcess(deviceId: string): any { }
90+
8991
public startSimulator(): IFuture<void> {
9092
return Future.fromResult();
9193
}

lib/iphone-simulator-xcode-6.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ export class XCode6Simulator extends iPhoneSimulatorBaseLib.IPhoneInteropSimulat
8888
return common.printDeviceLog(deviceId, launchResult);
8989
}
9090

91+
public getDeviceLogProcess(deviceId: string): any {
92+
return common.getDeviceLogProcess(deviceId);
93+
}
94+
9195
public startSimulator(): IFuture<void> {
9296
let device = this.devices[0];
9397
return common.startSimulator(device.id);

lib/iphone-simulator-xcode-7.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export class XCode7Simulator extends IPhoneSimulatorNameGetter implements ISimul
104104
return common.printDeviceLog(deviceId, launchResult);
105105
}
106106

107+
public getDeviceLogProcess(deviceId: string): any {
108+
return common.getDeviceLogProcess(deviceId);
109+
}
110+
107111
private getDeviceToRun(): IFuture<IDevice> {
108112
return (() => {
109113
let devices = this.simctl.getDevices().wait(),

lib/iphone-simulator-xcode-8.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export class XCode8Simulator extends IPhoneSimulatorNameGetter implements ISimul
104104
return common.printDeviceLog(deviceId, launchResult);
105105
}
106106

107+
public getDeviceLogProcess(deviceId: string): any {
108+
return common.getDeviceLogProcess(deviceId);
109+
}
110+
107111
private getDeviceToRun(): IFuture<IDevice> {
108112
return (() => {
109113
let devices = this.simctl.getDevices().wait(),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ios-sim-portable",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "",
55
"main": "./lib/ios-sim.js",
66
"scripts": {

0 commit comments

Comments
 (0)