Skip to content

Commit

Permalink
fix: use browserLogger for errors in the browser (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext authored Oct 29, 2024
1 parent a157b9a commit 647c904
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/logger/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import debug from "debug";

import browserLogger from "./browser";
import structuredLogger, { StructuredLogger } from "./structuredLogger";

if (typeof window !== "undefined") {
Expand Down Expand Up @@ -53,6 +54,11 @@ type ChildKey =
| "trpc"
| "ui";

const errorLogger =
typeof window === "undefined"
? structuredLogger.error.bind(structuredLogger)
: browserLogger.error.bind(browserLogger);

/**
* The AI logger uses namespaces so that we can selectively toggle noisy logs.
* Logs are selected with the DEBUG environment variable.
Expand All @@ -73,7 +79,7 @@ export function aiLogger(childKey: ChildKey) {
return {
info: debugLogger,
warn: debugLogger,
error: structuredLogger.error.bind(structuredLogger),
error: errorLogger.bind(structuredLogger),
};
}

Expand Down

0 comments on commit 647c904

Please sign in to comment.