oras
oras copied to clipboard
Consistent logging through the project
What is the version of your ORAS CLI
0.16.0
What would you like to be added?
Currently the project includes logrus which is fine, but logging is inconsistent and does not show the best separation of concerns. Ideally, this code should be capable of being used as an CLI executable and a go module.
- It should have some interface users can implement if they want to use their own logging.
- It should be initialized with a log level, which I suppose would be dictated by
--debugand--verbose, but it should not know about those command line options - It should not expose its implementation
- It should not know about objects related to this project
Reference current situation:
- https://github.com/oras-project/oras/blob/main/cmd/oras/internal/option/common.go#L32:L49
- https://github.com/oras-project/oras/blob/main/cmd/oras/internal/display/print.go#L47:L58
Why is this needed for ORAS?
Make the code more usable by other projects.
Are you willing to submit PRs to contribute to this feature?
- [ ] Yes, I am willing to implement it.
The oras CLI is not meant to be used as a go module. Users should only consume oras as an CLI executable.
Developers who are looking for an oras go module should take a look at oras-go.
FYI: For consistent logging as an CLI executable, there is an existing issue: https://github.com/oras-project/oras/issues/638
Reference current situation:
- https://github.com/oras-project/oras/blob/main/cmd/oras/internal/option/common.go#L32:L49
- https://github.com/oras-project/oras/blob/main/cmd/oras/internal/display/print.go#L47:L58
The mentioned situations cover totally different user scenarios. The former is targeted on stderr output for correlated http tracing, the latter focuses on timely status logging to stdout and might be extended to one-time structured output or maybe CLI progress bars if stdout is a terminal.
Well, there is logging and there is output. I think the logging should all be routed to stderr like errors, debug output and verbose output. And then there is display output like you'd get from oras repo tags that should have another object to manage.
@TerryHowe Are you suggesting that you found some current output that should be replaced with logs?
there is display output like you'd get from oras repo tags that should have another object to manage.
Are you suggesting the preview warning should not be managed by logger but something else?
cc @FeynmanZhou
From the call maybe we need to break this out into specific issues @TerryHowe
Done.