Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime/logging: actually do not panic when rctx is missing #6506

Merged
Merged
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
9 changes: 7 additions & 2 deletions runtime/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ type loggingPrintHook struct {
func (h loggingPrintHook) Print(pctx print.Context, msg string) error {
// NOTE(tsandall): if the request context is not present then do not panic,
// just log the print message without the additional context.
rctx, _ := logging.FromContext(pctx.Context)
fields := rctx.Fields()
var fields map[string]any
rctx, ok := logging.FromContext(pctx.Context)
if ok {
fields = rctx.Fields()
} else {
fields = make(map[string]any, 1)
}
fields["line"] = pctx.Location.String()
h.logger.WithFields(fields).Info(msg)
return nil
Expand Down