plugins
plugins copied to clipboard
Adding context using zaplogger results in the wrong type
s.logger has type *log.Logger, which is a wrapper for *zap.SugaredLogger. Since the rest of the system is also using the same wrapper, everything is fine... until:
logger := s.logger.With(
"req", ctx.Value(middleware.RequestIDKey),
"companyID", p.CompanyID,
"vendorID", p.VendorID,
)
Now logger has type *zap.SugaredLogger and can't be passed to functions that expect *log.Logger. It seems like it should be possible to cast it, but that gives me a type conversion error.
I'm pretty sure I'm missing something, but since the zaplogger plugin offers context logging it seems like this should work, and it might be useful to document the use of context logging in the calc example.
I'm using go 1.17.5, goa 3.5.3, and goa plugins v3.5.3. Thanks in advance!
I would recommend only using the *log.Logger type when instantiating the Goa middleware and using the "native" zap logger for the rest of the code. The plugin might need a bit of tweaking to enable that, maybe @hirosassa has some ideas?
Thank you for letting me know! I'll take a look tonight (I mean in JST).
Is it solved?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.