From 2c495c3f3a9a2c7510f47cc9131ac38e08c2d80c Mon Sep 17 00:00:00 2001 From: Tsvetan Raikov Date: Tue, 11 Oct 2016 11:40:26 +0300 Subject: [PATCH] Added CLI specific log filter for iOS --- lib/bootstrap.ts | 2 ++ lib/common | 2 +- lib/services/ios-log-filter.ts | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 lib/services/ios-log-filter.ts diff --git a/lib/bootstrap.ts b/lib/bootstrap.ts index be500d4a66..945e6c125c 100644 --- a/lib/bootstrap.ts +++ b/lib/bootstrap.ts @@ -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"); diff --git a/lib/common b/lib/common index cd060a4537..0408d3b1ec 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit cd060a4537a99c34c5c71217ff162773439118ef +Subproject commit 0408d3b1ecb4b42f35fc4152961c263173ffaca7 diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts new file mode 100644 index 0000000000..76b50b853c --- /dev/null +++ b/lib/services/ios-log-filter.ts @@ -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: + // [pid] CONSOLE LOG file:///location:row:column: + // 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);