-
Notifications
You must be signed in to change notification settings - Fork 649
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
Add logger to bbolt #509
Comments
I'm a little out of touch with golang slog, but it's better to take an existing logging interface then rollout your own. For picking:
|
Please assign it to me. I assume the first step is to add logs that are sufficient to trace each error, right?
I've go over the two links. Seems that slog is not intended to be used as a log interface, and there is an open issue for logr discussing implementing logr using slog, therefore I think logr is a better choice. I think we may use(or copy) https://github.com/go-logr/stdr as our default implementation. |
Proposal 1:Just as I mentioned in #509 (comment), we follow the same way as what we does for etcd and raft.
The minor concern is there is duplicated Logger interface definition in both bbolt and raft. It should be extracted into a separate common repo. The other concern is that it isn't structured log. It isn't a big problem for etcd, because the log will be encapsulated into JSON format by etcd. Proposal 2:
The good side is it's structured log. The concern of this proposal is logr only has etcd already has a flag
|
A library should not output any logs by default. That is application's responsibility. We can provide a logger field that users can override with their own implementation. |
Basically agree with this. Otherwise the bbolt CLI may output some unexpected log messages as well. We can set the default logger to discardLogger, so that the logger always points to a valid instance, and accordingly we don't need to check nil pointer something like |
Proposal 3:Use https://pkg.go.dev/golang.org/x/exp/slog as it is more likely to get adopted by the community and become a standard. The user can chose whatever handler he want want with it. |
We do not need fancy features, we just need a simple logger interface, so that users can provide whatever logger implementation they want. Note that etcd already uses |
what happened ? |
We also need to add log messages. I am doing it. Also read #509 (comment) |
@ahrtr hello ✋🏽 can u push the changes you made to log messages, and i will continue ? |
Done. |
Currently bbolt only returns error to caller. It should support printing log message as well.
We can follow the same way as raft does,
The text was updated successfully, but these errors were encountered: