-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
libcontainer logging #3434
Comments
One other thing somewhat releated to this issue is getting rid of logrus entirely, since it is no longer maintained. I am not sure though if there's a better alternative that supports at least JSON output. Maybe @thaJeztah has some ideas? |
Alternatively, libcontainer can have a build tag to disable any logging -- by creating a shallow logrus implementation. Not sure if that's a good idea, just thinking out loud here. |
Yeh, there may be alternatives to logrus, OTOH, it's still widely used (and I think I was given write access to that repository in case urgent things are needed). One option could be to use a "context logger", similar to how containerd approaches this; in this case the logger can be attached to the context, so we can still pass it (but others may skip that); https://github.com/containerd/containerd/blob/main/log/context.go Overall, I agree that for library code, logging should be optional (at least). In this specific case ( |
We recently spent some time finding a logger and ended up choosing https://github.com/uber-go/zap for a custom logger wrapper we're currently writing at work. But as @thaJeztah said, it's still widely used and we still use it for a lot of our services. @thaJeztah do you mean using [1] - https://dave.cheney.net/2017/01/26/context-is-for-cancelation |
The issue in question is make libcontainer logging optional. In other words, if runc is using libcontainer, log all the way. If someone else is using libcontainer, do not log (by default). |
I found that some log printing for libcontainer has been added in https://gitee.com/src-openeuler/runc, you can refer to its related implementation |
There's also https://github.com/go-logr/logr, which tries to separate interface from implementation |
As pointed out by @mrunalp in #3433 (comment), libcontainer packages should not do any logging, since this is a library used by other users.
Unfortunately, libcontainer is also a part of
runc
which is a CLI tool and we expect it to do some logging.This can be solved by having a logger in libcontainer, which defaults to a shallow implementation that does nothing, and then runc can redefine it to use logrus. Something like
libcontainer.SetLogger()
perhaps (where the argument is logrus compatible logger).WDYT @opencontainers/runc-maintainers?
The text was updated successfully, but these errors were encountered: