Skip to content

Fix device log for API 23 #1232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions lib/providers/device-log-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

export class DeviceLogProvider implements Mobile.IDeviceLogProvider {
//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+?)\): (.*)/;
private static LINE_REGEX = /.\/(.+?)\s*\(\s*\d+?\): (.*)/;
// sample line is "11-23 12:39:07.310 1584 1597 I art : Background sticky concurrent mark sweep GC freed 21966(1780KB) AllocSpace objects, 4(80KB) LOS objects, 77% free, 840KB/3MB, paused 4.018ms total 158.629ms"
private static API_LEVEL_23_LINE_REGEX = /.+?\s+?(?:[A-Z]\s+?)([A-Za-z ]+?)\s+?\: (.*)/;

constructor(private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $logger: ILogger) { }
Expand All @@ -25,15 +27,12 @@ export class DeviceLogProvider implements Mobile.IDeviceLogProvider {

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]};
let match = lineText.match(DeviceLogProvider.LINE_REGEX) || lineText.match(DeviceLogProvider.API_LEVEL_23_LINE_REGEX);
if (match && acceptedTags.indexOf(match[1].trim()) !== -1) {
return {tag: match[1].trim(), message: match[2]};
}
return null;
let matchingTag = _.any(acceptedTags, (tag: string) => { return lineText.indexOf(tag) !== -1; });
return matchingTag ? { message: lineText } : null;
}
}
$injector.register("deviceLogProvider", DeviceLogProvider);