diff --git a/lib/common b/lib/common index f6199c1aba..faecc232ea 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit f6199c1aba146f269251ef42f551d180869ddf9a +Subproject commit faecc232ea012730d7a02352e2ea1887d1343a25 diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts index 47c627b7ac..6c7f48300f 100644 --- a/lib/services/ios-log-filter.ts +++ b/lib/services/ios-log-filter.ts @@ -1,13 +1,14 @@ let sourcemap = require("source-map"); import * as path from "path"; +import fs = require("fs"); export class IOSLogFilter implements Mobile.IPlatformLogFilter { private $projectData: IProjectData; + private partialLine: string = null; - constructor( - private $fs: IFileSystem, - private $loggingLevels: Mobile.ILoggingLevels) { } + constructor(private $fs: IFileSystem, private $loggingLevels: Mobile.ILoggingLevels) { + } public filterData(data: string, logLevel: string, pid?: string): string { @@ -15,25 +16,44 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter { return null; } + let skipLastLine = data[data.length-1] !== "\n"; + 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 unnecessary information from log messages. The output looks like: - // CONSOLE LOG file:///location:row:column: - if (pid) { - let searchString = "["+pid+"]: "; - let pidIndex = data.indexOf(searchString); - if (pidIndex > 0) { - data = data.substring(pidIndex + searchString.length, data.length); + let lines = data.split("\n"); + let result = ""; + for (let i = 0; i [pid] CONSOLE LOG file:///location:row:column: + // This code removes unnecessary information from log messages. The output looks like: + // CONSOLE LOG file:///location:row:column: + if (pid) { + let searchString = "["+pid+"]: "; + let pidIndex = line.indexOf(searchString); + if (pidIndex > 0) { + line = line.substring(pidIndex + searchString.length, line.length); + this.getOriginalFileLocation(line); + result += this.getOriginalFileLocation(line) + "\n"; + continue; + } + } + if (skipLastLine && i === lines.length-1) { + this.partialLine = line; + } else { + result += this.getOriginalFileLocation(line) + "\n"; } } - data = this.getOriginalFileLocation(data); - return data.trim(); + return result; } return data; @@ -47,11 +67,11 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter { if (parts.length >= 4) { let file = parts[0]; if (this.ensureProjectData()) { - let sourceMapFile = path.join(this.$projectData.projectDir, file + ".map"); - let row = parseInt(parts[1]); - let column = parseInt(parts[2]); - if (this.$fs.exists(sourceMapFile).wait()) { - let sourceMap = this.$fs.readText(sourceMapFile, "utf8").wait(); + let sourceMapFile = path.join(this.$projectData.projectDir, file + ".map"); + let row = parseInt(parts[1]); + let column = parseInt(parts[2]); + if (fs.existsSync(sourceMapFile)) { + let sourceMap = fs.readFileSync(sourceMapFile, "utf8"); let smc = new sourcemap.SourceMapConsumer(sourceMap); let originalPosition = smc.originalPositionFor({line:row,column:column}); let sourceFile = smc.sources.length > 0 ? file.replace(smc.file, smc.sources[0]) : file;