From 5d737cf2e7a1a305d7ef0bee99c07c17d80233c8 Mon Sep 17 00:00:00 2001 From: alvarius Date: Fri, 8 Dec 2023 19:01:39 +0100 Subject: [PATCH] chore: pipe debug logs to stdout, add separate util to pipe to stderr (#2044) --- .changeset/rich-worms-deliver.md | 12 ++++++++++++ packages/abi-ts/src/debug.ts | 7 +++++++ packages/block-logs-stream/src/debug.ts | 7 +++++++ packages/cli/src/debug.ts | 7 +++++++ packages/cli/src/deploy/debug.ts | 7 +++++++ packages/common/src/codegen/debug.ts | 7 +++++++ packages/common/src/debug.ts | 7 +++++++ packages/faucet/src/debug.ts | 7 +++++++ packages/store-indexer/src/debug.ts | 7 +++++++ packages/store-sync/src/debug.ts | 7 +++++++ packages/store-sync/src/postgres-decoded/debug.ts | 7 +++++++ packages/store-sync/src/postgres/debug.ts | 7 +++++++ packages/store-sync/src/recs/debug.ts | 7 +++++++ packages/store-sync/src/sqlite/debug.ts | 7 +++++++ packages/store-sync/src/zustand/debug.ts | 7 +++++++ 15 files changed, 110 insertions(+) create mode 100644 .changeset/rich-worms-deliver.md diff --git a/.changeset/rich-worms-deliver.md b/.changeset/rich-worms-deliver.md new file mode 100644 index 0000000000..5fb443d46f --- /dev/null +++ b/.changeset/rich-worms-deliver.md @@ -0,0 +1,12 @@ +--- +"@latticexyz/abi-ts": patch +"@latticexyz/block-logs-stream": patch +"@latticexyz/cli": patch +"@latticexyz/common": patch +"@latticexyz/faucet": patch +"@latticexyz/store-indexer": patch +"@latticexyz/store-sync": patch +"@latticexyz/store": patch +--- + +Updated the `debug` util to pipe to `stdout` and added an additional util to explicitly pipe to `stderr` when needed. diff --git a/packages/abi-ts/src/debug.ts b/packages/abi-ts/src/debug.ts index 0a6bdd3149..dc6bc4fc1c 100644 --- a/packages/abi-ts/src/debug.ts +++ b/packages/abi-ts/src/debug.ts @@ -1,3 +1,10 @@ import createDebug from "debug"; export const debug = createDebug("abi-ts"); +export const error = createDebug("abi-ts"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/block-logs-stream/src/debug.ts b/packages/block-logs-stream/src/debug.ts index b6536cc8aa..fc9c848b1e 100644 --- a/packages/block-logs-stream/src/debug.ts +++ b/packages/block-logs-stream/src/debug.ts @@ -1,3 +1,10 @@ import createDebug from "debug"; export const debug = createDebug("mud:block-events-stream"); +export const error = createDebug("mud:block-events-stream"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/cli/src/debug.ts b/packages/cli/src/debug.ts index 9fa84e5a8b..a14afdac1c 100644 --- a/packages/cli/src/debug.ts +++ b/packages/cli/src/debug.ts @@ -1,3 +1,10 @@ import createDebug from "debug"; export const debug = createDebug("mud:cli"); +export const error = createDebug("mud:cli"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/cli/src/deploy/debug.ts b/packages/cli/src/deploy/debug.ts index f13686a964..2642d0b81a 100644 --- a/packages/cli/src/deploy/debug.ts +++ b/packages/cli/src/deploy/debug.ts @@ -1,3 +1,10 @@ import { debug as parentDebug } from "../debug"; export const debug = parentDebug.extend("deploy"); +export const error = parentDebug.extend("deploy"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/common/src/codegen/debug.ts b/packages/common/src/codegen/debug.ts index ab1807cb00..e74c9395c4 100644 --- a/packages/common/src/codegen/debug.ts +++ b/packages/common/src/codegen/debug.ts @@ -1,3 +1,10 @@ import { debug as parentDebug } from "../debug"; export const debug = parentDebug.extend("codegen"); +export const error = parentDebug.extend("codegen"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/common/src/debug.ts b/packages/common/src/debug.ts index 265b1c4086..562273227b 100644 --- a/packages/common/src/debug.ts +++ b/packages/common/src/debug.ts @@ -1,3 +1,10 @@ import createDebug from "debug"; export const debug = createDebug("mud:common"); +export const error = createDebug("mud:common"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/faucet/src/debug.ts b/packages/faucet/src/debug.ts index a6dd8eec29..9b38ca7715 100644 --- a/packages/faucet/src/debug.ts +++ b/packages/faucet/src/debug.ts @@ -1,3 +1,10 @@ import createDebug from "debug"; export const debug = createDebug("mud:faucet"); +export const error = createDebug("mud:faucet"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/store-indexer/src/debug.ts b/packages/store-indexer/src/debug.ts index 191fdbff78..3b5022af98 100644 --- a/packages/store-indexer/src/debug.ts +++ b/packages/store-indexer/src/debug.ts @@ -1,3 +1,10 @@ import createDebug from "debug"; export const debug = createDebug("mud:store-indexer"); +export const error = createDebug("mud:store-indexer"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/store-sync/src/debug.ts b/packages/store-sync/src/debug.ts index b8d8179922..158d7e255f 100644 --- a/packages/store-sync/src/debug.ts +++ b/packages/store-sync/src/debug.ts @@ -1,3 +1,10 @@ import createDebug from "debug"; export const debug = createDebug("mud:store-sync"); +export const error = createDebug("mud:store-sync"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/store-sync/src/postgres-decoded/debug.ts b/packages/store-sync/src/postgres-decoded/debug.ts index 607afe7505..b2776f9926 100644 --- a/packages/store-sync/src/postgres-decoded/debug.ts +++ b/packages/store-sync/src/postgres-decoded/debug.ts @@ -1,3 +1,10 @@ import { debug as parentDebug } from "../debug"; export const debug = parentDebug.extend("postgres-decoded"); +export const error = parentDebug.extend("postgres-decoded"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/store-sync/src/postgres/debug.ts b/packages/store-sync/src/postgres/debug.ts index 306f33b44b..80a72ffddb 100644 --- a/packages/store-sync/src/postgres/debug.ts +++ b/packages/store-sync/src/postgres/debug.ts @@ -1,3 +1,10 @@ import { debug as parentDebug } from "../debug"; export const debug = parentDebug.extend("postgres"); +export const error = parentDebug.extend("postgres"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/store-sync/src/recs/debug.ts b/packages/store-sync/src/recs/debug.ts index 0b392b2333..960097a3e7 100644 --- a/packages/store-sync/src/recs/debug.ts +++ b/packages/store-sync/src/recs/debug.ts @@ -1,3 +1,10 @@ import { debug as parentDebug } from "../debug"; export const debug = parentDebug.extend("recs"); +export const error = parentDebug.extend("reccs"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/store-sync/src/sqlite/debug.ts b/packages/store-sync/src/sqlite/debug.ts index 6a9887eb16..90a24d0f95 100644 --- a/packages/store-sync/src/sqlite/debug.ts +++ b/packages/store-sync/src/sqlite/debug.ts @@ -1,3 +1,10 @@ import { debug as parentDebug } from "../debug"; export const debug = parentDebug.extend("sqlite"); +export const error = parentDebug.extend("sqlite"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/store-sync/src/zustand/debug.ts b/packages/store-sync/src/zustand/debug.ts index 67cd7cbf12..17b30372b4 100644 --- a/packages/store-sync/src/zustand/debug.ts +++ b/packages/store-sync/src/zustand/debug.ts @@ -1,3 +1,10 @@ import { debug as parentDebug } from "../debug"; export const debug = parentDebug.extend("zustand"); +export const error = parentDebug.extend("zustand"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console);