Skip to content

Commit

Permalink
Debugger messages marked as "debug" (shown in console) (#1545)
Browse files Browse the repository at this point in the history
[byn] tag changed to [app]
  • Loading branch information
christianlent authored Mar 4, 2020
1 parent d97835b commit 94e1a01
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/xarc-app-dev/lib/dev-admin/log-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`<yellow.inverse>[fyi]</> `;
const BunyanTag = ck`<cyan.inverse>[byn]</> `;
const BunyanTag = ck`<cyan.inverse>[app]</> `;
const NodeDebuggerTag = "[nod] ";
const BunyanLevelLookup = {
60: "error",
50: "error",
Expand All @@ -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}
];

Expand Down
14 changes: 14 additions & 0 deletions packages/xarc-app-dev/test/spec/dev-admin/log-parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});

0 comments on commit 94e1a01

Please sign in to comment.