Add out-of-the-box zap logger
Closed this issue · 3 comments
What is the underlying problem you're trying to solve?
Embedding OPA as an SDK in a service currently means either:
- You get lucky and you use logrus
- You have both logrus and whatever log implementation your service uses
- You have to implement logging.Logger for your log implementation
This is all surmountable but it may be a nice quality of life improvement to have common log implementation wrappers in the core OPA library.
Describe the ideal solution
Ideally I could just do something like:
opa, err := sdk.New(context.Background(), sdk.Options{
Logger: opazap.Wrap(logger),
})
and get on with my day.
Describe a "Good Enough" solution
Unfortunately the SetLevel
function means you also need to pass a zap.AtomicLevel
:
opa, err := sdk.New(context.Background(), sdk.Options{
Logger: opazap.Wrap(logger, level),
})
A better solution would be very welcome.
Additional Context
I have a proposed implementation which I will pull request shortly.
💭 Now what "log/slog" has appeared, would that provide a no-dependencies common ground for multiple logging implementations to plug in? Honest question, I haven't played with it much yet.
log/slog
seems like it could be a good integration point (similar to you I haven't had much hands on time with it yet). I think it would certainly be worth looking at that once the module minimum Go version is up to 1.21.
Ah, minimal go version. Yeah, thanks for checking that.