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
Hi. One of main use cases I know for logger fields is to append more stuff as you go, but the return difference between Logger() and Ctx() makes it quite weird.
The snippet above won't work, because Ctx() returns *Logger while Logger() returns Logger (non-pointer).
In order for it to work we need to modify the snippet to:
In this case log is not the same logger, that you've got from context. If you try to log.UpdateContext(...) your logger in r.Context() wouldn't change.
So I guess, that pointer here defines shared Logger vs local instance.
Hi. One of main use cases I know for logger fields is to append more stuff as you go, but the return difference between
Logger()
andCtx()
makes it quite weird.Let's say we have this code snippet:
The snippet above won't work, because
Ctx()
returns*Logger
whileLogger()
returnsLogger
(non-pointer).In order for it to work we need to modify the snippet to:
or
which doesn't look ideal.
Am I missing something or perhaps this use case is too obscure?
The text was updated successfully, but these errors were encountered: