-
Notifications
You must be signed in to change notification settings - Fork 345
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
Replace pulsar/log
and logrus with slog
#1078
Comments
slog
pulsar/log
and logrus with slog
IIRC pulsar-client-go still supports Go 1.15. What do you think of the migrating plan? As long as we declare to support versions before 1.21, we cannot fully adopt the Besides, how do you compare among |
It's less about functionality, and more about future-proofing, since there will now be standard types that can serve as a compatibility layer without forcing a non-stdlib dependency for implementation. Right now, there are some difficulties I have with the standard logger, where I'm kind of locked in to how I deal with them:
If I want to change any of these things, I must implement the entire interface, including more complex methods such as If the library takes a
This issue has two parts: support for Go versions and semver compatibility on As far as semver goes, change to the logging interface would have to wait for a major revision number. I don't know if there are any plans to move to With Go versions, I think that it is okay to follow the support lifecycle of Go itself, which means two minor versions. That would currently put us at 1.20. 1.19 and older are EOL as far as Go is concerned. With the compatibility promise, it does not make much sense to declare explicit support for older versions. This at least opens up the possibility to support |
### Motivation This commit supports to use `log/slog` package from the standard library to control the level and output type of the logs. In order for us to not have to import logrus as a direct dependency for part of our testing suit, it would be nice if we can use `slog` package instead, and wrap that in the provided by `pulsar/log` interfaces. This ties in a bit with issue #1078 because it opens the door for users who are already working with log/slog in their projects. Plus, it's a gives more time for the Pulsar team to evaluate incorporating slog into the SDK. ### Modifications One additional file `/pulsar/log/wrapper_slog.go` is added. One additional function in the `pulsar/log` package, `NewLoggerWithSlog` , is exposed.
Closed by #1234 |
Is your feature request related to a problem? Please describe.
pulsar/log.Logger
is a pain to use since it is an interface that returns package types, thus coupling any implementation toclient-pulsar-go
and all of its dependencies, including logrus.The good news is that go 1.21.0 is out, and with it comes a standard, structured logger in the stdlib: https://pkg.go.dev/log/slog Standardizing on the
*slog.Logger
type, would provide all of the features exercised by the current logging interface, and would future-proof the package against needing to have external logging dependencies for the foreseeable future.Describe the solution you'd like
The entire
pulsar/log
package should be removed and replaced withslog
integrationAdditional context
There might be a way to make this change without breaking semver, but at the very least this should be a requirement before any jump to 1.0, since it will effectively end the requirement on non-stdlib logging forever.
The text was updated successfully, but these errors were encountered: