Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): logs print causes instead of [Object] #16642

Mergedsaphid(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/16642/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 107 additions and 2 deletions.

x
0 of 2 viewed, 2 left
66 additions and 0 deletionsapps/server/src/serverLogger.test.tsModified
View file
@@ -1,12 +1,16 @@
import * as NodePath from "@effect/platform-node/NodePath";
import { assert, describe, it } from "@effect/vitest";
import * as NodeOS from "node:os";
+import * as NodeUtil from "node:util";
+​
import { ExternalLauncherBrowserSpawnError } from "@t3tools/contracts";
import * as Cause from "effect/Cause";
import * as ConfigProvider from "effect/ConfigProvider";
+import * as Console from "effect/Console";
import * as Effect from "effect/Effect";
import * as Exit from "effect/Exit";
import * as Layer from "effect/Layer";
+import * as Redactable from "effect/Redactable";
import * as Path from "effect/Path";
import * as Tracer from "effect/Tracer";
import * as HttpClient from "effect/http/HttpClient";
@@ -147,6 +151,25 @@
return { requests, spans };
});
​
+/** Logs one warning through the server logger and returns what its console printed. */
+const printThroughConsole = (fields: object) =>
+ Effect.gen(function* () {
+ const printed: Array<string> = [];
+ const testConsole = {
+ ...globalThis.console,
+ log: (...args: ReadonlyArray<unknown>) => {
+ printed.push(NodeUtil.format(...args));
+ },