Skip to content

Added CLI specific log filter for iOS #2116

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
Oct 11, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@ $injector.require("messages", "./common/messages/messages");
$injector.require("xmlValidator", "./xml-validator");

$injector.requireCommand("devices", "./commands/devices");

$injector.require("iOSLogFilter", "./services/ios-log-filter");
35 changes: 35 additions & 0 deletions lib/services/ios-log-filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export class IOSLogFilter implements Mobile.IPlatformLogFilter {

constructor(private $loggingLevels: Mobile.ILoggingLevels) { }

public filterData(data: string, logLevel: string, pid?: string): string {

if (pid && data && data.indexOf(`[${pid}]`) === -1) {
return null;
}

if (data) {
if (data.indexOf("SecTaskCopyDebugDescription") !== -1 ||
data.indexOf("NativeScript loaded bundle") !== -1 ||
(data.indexOf("assertion failed:") !== -1 && data.indexOf("libxpc.dylib") !== -1)) {
return null;
}
// CONSOLE LOG messages comme in the following form:
// <date> <domain> <app>[pid] CONSOLE LOG file:///location:row:column: <actual message goes here>
// This code removes the first part and leaves only the message as specified by the call to console.log function.
// This removes the unnecessary information and makes the log consistent with Android.
let logIndex = data.indexOf("CONSOLE LOG");
if (logIndex !== -1) {
let i = 4;
while(i) { logIndex = data.indexOf(':', logIndex+1); i --; }
if (logIndex > 0) {
data = "JS:" + data.substring(logIndex+1, data.length);
}
}
return data.trim();
}

return data;
}
}
$injector.register("iOSLogFilter", IOSLogFilter);