| 37 | this.doSetAllBreakpoint([], false, true); // break on exceptions |
| 38 | } |
| 39 | onLogged(path, line, data) { |
| 40 | this.log += data; |
| 41 | if (this.log.endsWith("\n")) { |
| 42 | if (this.log.startsWith("|:") && this.log.endsWith(":|\n")) { |
| 43 | const payload = this.log.slice(2, this.log.length - 3); |
| 44 | if (payload.startsWith("@filename ")) { |
| 45 | const parts = payload.split(" "); |
| 46 | if (parts[1]) |
| 47 | this.binaryName = parts[1]; |
| 48 | } |
| 49 | else if (payload.startsWith("@close")) { |
| 50 | if (this.binaryOutput) { |
| 51 | fs.closeSync(this.binaryOutput); |
| 52 | console.log(`#xsbug-log capture: ${this.binaryPath}`); |
| 53 | } |
| 54 | delete this.binaryOutput; |
| 55 | delete this.binaryName; |
| 56 | delete this.binaryPath; |
| 57 | } |
| 58 | else if (payload.startsWith("@")) { |
| 59 | console.log(`ignoring ${payload}`); |
| 60 | } |
| 61 | else if (payload) { |
| 62 | if (!this.binaryOutput) { |
| 63 | this.binaryPath = process.env.MODDABLE + "/build/tmp/" + (this.binaryName ? this.binaryName : "log.bin"); |
| 64 | this.binaryOutput = fs.openSync(this.binaryPath, "w+"); |
| 65 | } |
| 66 | fs.writeSync(this.binaryOutput, Buffer.from(payload, "base64"), 0); |
| 67 | } |
| 68 | } |
| 69 | else |
| 70 | console.log(this.log.slice(0, this.log.length - 1)); |
| 71 | this.log = ""; |
| 72 | } |
| 73 | } |
| 74 | onBroken(path, line, text) { |
| 75 | this.view.frames.forEach((frame, index) => { |
| 76 | let line = " #" + index + ": " + frame.name; |