Skip to content

add AddCallerSkip(1) so we aren't having the logger log itself#2182

Draft
matthewlouisbrockman wants to merge 3 commits intomainfrom
fix-logging-logger-as-origin
Draft

add AddCallerSkip(1) so we aren't having the logger log itself#2182
matthewlouisbrockman wants to merge 3 commits intomainfrom
fix-logging-logger-as-origin

Conversation

@matthewlouisbrockman
Copy link
Contributor

@matthewlouisbrockman matthewlouisbrockman commented Mar 20, 2026

cleans up logs by logging the root location the log occured rather than the location of the logger

previous behavior for, e.g. Cluster instances: Failed to synchronize would show the lgger as the code logging:

code_file_path /build/shared/pkg/logger/logger.go code_function_name github.com/e2b-dev/infra/packages/shared/pkg/logger.(*TracedLogger).Error code_line_number 142 code_stacktrace github.com/e2b-dev/infra/packages/shared/pkg/logger.(*TracedLogger).Error	/build/shared/pkg/logger/logger.go:142 github.com/e2b-dev/infra/packages/shared/pkg/synchronization.(*Synchronize[...]).Start	/build/shared/pkg/synchronization/synchronization.go:75 detected_level error 

now, we get what actually called the logger

code_file_path /build/shared/pkg/synchronization/synchronization.go code_function_name github.com/e2b-dev/infra/packages/shared/pkg/synchronization.(*Synchronize[...]).Start code_line_number 75 code_stacktrace github.com/e2b-dev/infra/packages/shared/pkg/synchronization.(*Synchronize[...]).Start	/build/shared/pkg/synchronization/synchronization.go:75 detected_level error 

Note

Low Risk
Low risk: changes only logging metadata (caller attribution) and adds tests, but it may affect downstream log parsing/alerting that depends on caller fields.

Overview
Updates TracedLogger construction to always enable caller reporting with zap.AddCallerSkip(1) so logs point at the original call site instead of the wrapper, while GRPCLogger now disables caller emission to avoid incorrect gRPC middleware attribution; adds tests to ensure caller file/line are correct and that L() doesn’t double-apply caller skipping after ReplaceGlobals.

Written by Cursor Bugbot for commit b9136c6. This will update automatically on new commits. Configure here.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f6b10a44e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

zap.AddCaller(),
zap.AddCallerSkip(1),
)
}
Copy link

Choose a reason for hiding this comment

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

Detach() leaks AddCallerSkip(1) to direct logger consumers

Low Severity

withTraceLoggerOptions embeds AddCallerSkip(1) into the inner *zap.Logger, which is designed to skip the TracedLogger wrapper. However, Detach() exposes this inner logger directly. Callers that use the detached logger without a TracedLogger wrapper (e.g., zapio.Writer in process.go) will have their reported caller shifted by one extra frame, since there's no wrapper frame to skip. Callers using .Core() are unaffected since core extraction discards options.

Additional Locations (1)
Fix in Cursor Fix in Web
@ValentaTomas ValentaTomas removed their request for review March 21, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants