You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the context.Context part of the readme, when attaching a Go context, this is the example given (notice that the context is added prior to the event):
Whereas, the second form of a Go context integration has a small, seemingly insignificant line, about passing the current context.Context into the logged event, which is then retrieved from hooks. The example given:
ctx:=context.Background()
// Use the Ctx function to make the context available to the hooklogger.Info().Ctx(ctx).Msg("Hello")
Spent some time debugging this yesterday since our repository pattern was similar to the first, where most logs where structured like below:
log.Ctx(ctx).Info().Msg("")
When I implemented tracingHooks to append two Ids from context, they never appeared (they were logged as nil). It was not until a closer reading clued me towards using context AFTER the event, which then worked. Another example below:
Context prior to the event (i.e. log.Ctx(ctx).Info())::
I am curious to why this is the case, and requesting that the README be updated to call attention to this to help those after myself. If easiest, I can also submit a PR with a README callout, but would prefer to understand this discrepancy at a deeper level first.
The text was updated successfully, but these errors were encountered:
According to the context.Context part of the readme, when attaching a Go context, this is the example given (notice that the context is added prior to the event):
Whereas, the second form of a Go context integration has a small, seemingly insignificant line, about passing the current context.Context into the logged event, which is then retrieved from hooks. The example given:
Spent some time debugging this yesterday since our repository pattern was similar to the first, where most logs where structured like below:
When I implemented tracingHooks to append two Ids from context, they never appeared (they were logged as nil). It was not until a closer reading clued me towards using context AFTER the event, which then worked. Another example below:
Context prior to the event (i.e.
log.Ctx(ctx).Info()
)::Context after the event (i.e.
log.Info().Ctx(ctx)
):I am curious to why this is the case, and requesting that the README be updated to call attention to this to help those after myself. If easiest, I can also submit a PR with a README callout, but would prefer to understand this discrepancy at a deeper level first.
The text was updated successfully, but these errors were encountered: