oras icon indicating copy to clipboard operation
oras copied to clipboard

Consistent logging through the project

Open TerryHowe opened this issue 2 years ago • 6 comments

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 --debug and --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.

TerryHowe avatar Feb 03 '23 13:02 TerryHowe

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.

shizhMSFT avatar Feb 06 '23 14:02 shizhMSFT

FYI: For consistent logging as an CLI executable, there is an existing issue: https://github.com/oras-project/oras/issues/638

qweeah avatar Feb 11 '23 01:02 qweeah

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.

qweeah avatar Mar 12 '23 13:03 qweeah

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 avatar Apr 10 '23 13:04 TerryHowe

@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

qweeah avatar Apr 11 '23 09:04 qweeah

From the call maybe we need to break this out into specific issues @TerryHowe

sajayantony avatar Jul 19 '23 00:07 sajayantony

Done.

TerryHowe avatar Jul 18 '24 18:07 TerryHowe