diff --git a/packages/xarc-app-dev/lib/dev-admin/log-parser.js b/packages/xarc-app-dev/lib/dev-admin/log-parser.js index aee2f1fc6..16e9a2af8 100644 --- a/packages/xarc-app-dev/lib/dev-admin/log-parser.js +++ b/packages/xarc-app-dev/lib/dev-admin/log-parser.js @@ -7,10 +7,12 @@ const { Levels } = require("./log-reader"); const LogParse = /^(?:\u001b\[[0-9]+?m)?([a-z]+)(?:\u001b\[[0-9]+?m)?:(?: ([\s\S]*))?$/; // eslint-disable-next-line no-control-regex const FyiLogParse = /^(?:\u001b\[[0-9]+?m)?FYI ([a-z]+):(?:\u001b\[[0-9]+?m)?(?: ([\s\S]*))?$/; +const NodeParse = /(^Debugger listening)|(^For help, see: https:\/\/nodejs.org\/en\/docs)/; const UnhandledRejection = /([a-zA-Z]+): Unhandled rejection .*/; const FyiTag = ck`[fyi] `; -const BunyanTag = ck`[byn] `; +const BunyanTag = ck`[app] `; +const NodeDebuggerTag = "[nod] "; const BunyanLevelLookup = { 60: "error", 50: "error", @@ -25,6 +27,10 @@ const parsers = [ prefix: "" }, {regex: LogParse, prefix: ""}, + { + custom: (raw) => raw.match(NodeParse) ? [raw, "warn", raw] : undefined, + prefix: NodeDebuggerTag + }, {regex: FyiLogParse, prefix: FyiTag} ]; diff --git a/packages/xarc-app-dev/test/spec/dev-admin/log-parser.spec.js b/packages/xarc-app-dev/test/spec/dev-admin/log-parser.spec.js index 3cfc29552..b55d4fd72 100644 --- a/packages/xarc-app-dev/test/spec/dev-admin/log-parser.spec.js +++ b/packages/xarc-app-dev/test/spec/dev-admin/log-parser.spec.js @@ -110,4 +110,18 @@ describe("log-parser", function() { expect(level).equal("info"); expect(message).equal(raw); }); + + it("should mark the debugger listening message as a 'warn' so it is rendered to the console", () => { + const raw = "Debugger listening on ws://127.0.0.1:9229/75cf1993-daff-4533-a53e-30fb92a5ad16"; + const { level, message } = parse(raw); + expect(level).equal("warn"); + expect(message).equal("[nod] Debugger listening on ws://127.0.0.1:9229/75cf1993-daff-4533-a53e-30fb92a5ad16"); + }); + + it("should mark the inspector help message as a 'warn' so it is rendered to the console", () => { + const raw = "For help, see: https://nodejs.org/en/docs/inspector"; + const { level, message } = parse(raw); + expect(level).equal("warn"); + expect(message).equal("[nod] For help, see: https://nodejs.org/en/docs/inspector"); + }); });