diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts index 69274a5fa8..32fa60f712 100644 --- a/lib/services/ios-log-filter.ts +++ b/lib/services/ios-log-filter.ts @@ -3,7 +3,7 @@ import { injector } from "../common/yok"; export class IOSLogFilter implements Mobile.IPlatformLogFilter { // Used to recognize output related to the current project // This looks for artifacts like: AppName[22432] or AppName(SomeTextHere)[23123] - private appOutputRegex: RegExp = /([^\s\(\)]+)(?:\([^\s]+\))?\[[0-9]+\]/; + private appOutputRegex: RegExp = /([^\s\(\)]+)(?:\(([^\s]+)\))?\[[0-9]+\]/; // Used to trim the passed messages to a simpler output // Example: @@ -13,6 +13,14 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter { `^.*(?::|:|:|\\(NativeScript\\)|${this.appOutputRegex.source}:){1}` ); + // Used to post filter messages that slip through but are not coming from NativeScript itself. + // Looks for text in parenthesis at the beginning + // Example: + // (RunningBoardServices) [com.apple.runningboard:connection] Identity resolved as application<...> + // ^(~~capture group~~~)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + // we then use this to filter out non-NativeScript lines + protected postFilterRegex: RegExp = /^\((.+)\) \[com\.apple.+\]/; + private filterActive: boolean = true; private partialLine: string = null; @@ -59,6 +67,10 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter { // of this filter may be used accross multiple projects. const projectName = loggingOptions && loggingOptions.projectName; this.filterActive = matchResult[1] !== projectName; + + if (matchResult?.[2]) { + this.filterActive ||= matchResult[2] !== "NativeScript"; + } } if (this.filterActive) { @@ -71,6 +83,13 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter { } currentLine = currentLine.trim(); + + // post filtering: () check if is not "NativeScript" + const postFilterMatch = this.postFilterRegex.exec(currentLine); + if (postFilterMatch && postFilterMatch?.[1] !== "NativeScript") { + continue; + } + output += currentLine + "\n"; }