Skip to content
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
21 changes: 20 additions & 1 deletion lib/services/ios-log-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -13,6 +13,14 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter {
`^.*(?:<Notice>:|<Error>:|<Warning>:|\\(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;
Expand Down Expand Up @@ -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) {
Expand All @@ -71,6 +83,13 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter {
}

currentLine = currentLine.trim();

// post filtering: (<anything>) check if <anything> is not "NativeScript"
const postFilterMatch = this.postFilterRegex.exec(currentLine);
if (postFilterMatch && postFilterMatch?.[1] !== "NativeScript") {
continue;
}

output += currentLine + "\n";
}

Expand Down