Skip to content
Open
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 packages/core/lib/v3/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
// Per-instance routing using AsyncLocalStorage
const logContext = new AsyncLocalStorage<string>();
const instanceLoggers = new Map<string, (line: LogLine) => void>();
const FALLBACK_VERBOSITY = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: consider storing per-instance verbosity settings in a Map (similar to instanceLoggers) instead of hardcoding fallback verbosity. this would allow the fallback path to respect each instance's configured verbosity level.

const instanceVerbosity = new Map<string, 0 | 1 | 2>();

export function bindInstanceLogger(
  instanceId: string,
  logger: (line: LogLine) => void,
  verbosity: 0 | 1 | 2 = 1,
): void {
  instanceLoggers.set(instanceId, logger);
  instanceVerbosity.set(instanceId, verbosity);
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/lib/v3/logger.ts
Line: 34:34

Comment:
**style:** consider storing per-instance verbosity settings in a Map (similar to `instanceLoggers`) instead of hardcoding fallback verbosity. this would allow the fallback path to respect each instance's configured verbosity level.

```typescript
const instanceVerbosity = new Map<string, 0 | 1 | 2>();

export function bindInstanceLogger(
  instanceId: string,
  logger: (line: LogLine) => void,
  verbosity: 0 | 1 | 2 = 1,
): void {
  instanceLoggers.set(instanceId, logger);
  instanceVerbosity.set(instanceId, verbosity);
}
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.


export function bindInstanceLogger(
instanceId: string,
Expand Down Expand Up @@ -77,6 +78,10 @@ export function v3Logger(line: LogLine): void {
const levelStr = lvl === 0 ? "ERROR" : lvl === 2 ? "DEBUG" : "INFO";
let output = `[${ts}] ${levelStr}: ${line.message}`;

if (lvl > FALLBACK_VERBOSITY) {
return;
}
Comment on lines +81 to +83
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: hardcoded FALLBACK_VERBOSITY = 1 doesn't respect user's configured verbosity level

when user sets verbose: 2 (show debug), fallback will still suppress debug logs. when user sets verbose: 0 (errors only), fallback will show info logs.

this will also break the existing test at logger-initialization.spec.ts:311 which expects all 3 log levels (error, info, debug) to be logged to console fallback.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/lib/v3/logger.ts
Line: 81:83

Comment:
**logic:** hardcoded `FALLBACK_VERBOSITY = 1` doesn't respect user's configured verbosity level

when user sets `verbose: 2` (show debug), fallback will still suppress debug logs. when user sets `verbose: 0` (errors only), fallback will show info logs.

this will also break the existing test at `logger-initialization.spec.ts:311` which expects all 3 log levels (error, info, debug) to be logged to console fallback.

How can I resolve this? If you propose a fix, please make it concise.


if (line.auxiliary) {
for (const [key, { value, type }] of Object.entries(line.auxiliary)) {
let formattedValue = value;
Expand Down