Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/mean-parks-take.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

fix `console.debug` logs not being logged at the `info` level (as users expect)
4 changes: 4 additions & 0 deletions fixtures/worker-logs/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe("'wrangler dev' correctly displays logs", () => {
const output = await getWranglerDevOutput("module");
expect(output).toMatchInlineSnapshot(`
[
"<<<<< console.debug() message >>>>>",
"<<<<< console.info() message >>>>>",
"<<<<< console.log() message >>>>>",
"<<<<< stderr.write() message >>>>>",
Expand All @@ -72,6 +73,7 @@ describe("'wrangler dev' correctly displays logs", () => {
const output = await getWranglerDevOutput("module", ["--log-level=log"]);
expect(output).toMatchInlineSnapshot(`
[
"<<<<< console.debug() message >>>>>",
"<<<<< console.info() message >>>>>",
"<<<<< console.log() message >>>>>",
"<<<<< stderr.write() message >>>>>",
Expand All @@ -86,6 +88,7 @@ describe("'wrangler dev' correctly displays logs", () => {
const output = await getWranglerDevOutput("module", ["--log-level=info"]);
expect(output).toMatchInlineSnapshot(`
[
"<<<<< console.debug() message >>>>>",
"<<<<< console.info() message >>>>>",
"X [ERROR] <<<<< console.error() message >>>>>",
"▲ [WARNING] <<<<< console.warning() message >>>>>",
Expand Down Expand Up @@ -315,6 +318,7 @@ describe("'wrangler dev' correctly displays logs", () => {
]);
expect(output).toMatchInlineSnapshot(`
[
"<<<<< console.debug() message >>>>>",
"<<<<< console.info() message >>>>>",
"<<<<< console.log() message >>>>>",
"X [ERROR] <<<<< console.error() message >>>>>",
Expand Down
10 changes: 9 additions & 1 deletion packages/wrangler/src/dev/miniflare/stdio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,15 @@ function logStructuredLog(
}

if (level === "debug") {
return logger.debug(message);
// note that debug logs are logged at the info level, this is like so because before structured logs
// were introduced developers were used to call `console.debug` and get their logs in the terminal
// during local development and we don't want to break such workflow in a non-major release
// (For more context see: https://github.com/cloudflare/workers-sdk/issues/10690)
//
// TODO: for the next major release we do want the debug logs to be logged at the debug level instead,
// we should also introduce some mechanism to allows users to get their worker debug logs without
// also getting all the wrangler debug logs
return logger.info(message);
}

if (level === "error") {
Expand Down
Loading