Skip to content

Commit

Permalink
Merge pull request #1219 from NativeScript/fatme/show-app-output-by-l…
Browse files Browse the repository at this point in the history
…ivesync-command

Show application output from livesync command
  • Loading branch information
rosen-vladimirov committed Nov 20, 2015
2 parents 441f927 + d81817a commit 980ee5e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/commands/livesync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export class LivesyncCommand implements ICommand {
private $errors: IErrors) { }

public execute(args: string[]): IFuture<void> {
this.$options.justlaunch = true;
return this.$usbLiveSyncService.liveSync(args[0]);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/common
34 changes: 31 additions & 3 deletions lib/providers/device-log-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,38 @@
"use strict";

export class DeviceLogProvider implements Mobile.IDeviceLogProvider {
constructor(private $logger: ILogger) { }
//sample line is "I/Web Console( 4438): Received Event: deviceready at file:///storage/emulated/0/Icenium/com.telerik.TestApp/js/index.js:48"
private static LINE_REGEX = /.\/(.+?)\s*\(\s*(\d+?)\): (.*)/;

public logData(line: string, platform: string, deviceIdentifier: string): void {
this.$logger.out(line);
constructor(private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $logger: ILogger) { }

public logData(lineText: string, platform: string, deviceIdentifier: string): void {
if (!platform || platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
this.$logger.out(lineText);
} else if (platform === this.$devicePlatformsConstants.Android) {
let log = this.getConsoleLogFromLine(lineText);
if (log) {
if (log.tag) {
this.$logger.out(`${log.tag}: ${log.message}`);
} else {
this.$logger.out(log.message);
}
}
}
}

private getConsoleLogFromLine(lineText: String): any {
let acceptedTags = ["chromium", "Web Console", "JS"];
let match = lineText.match(DeviceLogProvider.LINE_REGEX);
if (match) {
if(acceptedTags.indexOf(match[1]) !== -1) {
return {tag: match[1], message: match[3]};
}
} else if (_.any(acceptedTags, (tag: string) => { return lineText.indexOf(tag) !== -1; })) {
return {message: match[3]};
}
return null;
}
}
$injector.register("deviceLogProvider", DeviceLogProvider);
4 changes: 0 additions & 4 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@ export class PlatformService implements IPlatformService {
return (() => {
platformData.platformProjectService.deploy(device.deviceInfo.identifier).wait();
device.deploy(packageFile, this.$projectData.projectId).wait();

if (!this.$options.justlaunch) {
device.openDeviceLogStream();
}
}).future<void>()();
};
this.$devicesService.execute(action).wait();
Expand Down

0 comments on commit 980ee5e

Please sign in to comment.