Skip to content

fix: route logger output to command stderr - #2123

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
vigneshakaviki:fix/logger-command-stderr
Aug 1, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
vigneshakaviki:fix/logger-command-stderr

Conversation

@vigneshakaviki

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Routes logger output through Cobra's configured error writer so applications using Command.SetErr capture warning and debug logs consistently with other stderr output.

Adds a focused unit test covering the configured writer.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1431

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

Local validation:

  • golangci-lint run ./...
  • go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... ./...
  • make build-mac-arm64

Linux-only E2E was not run locally; this embedding behavior is covered at the Cobra command/logger boundary by the focused unit test.

@vigneshakaviki
vigneshakaviki marked this pull request as ready for review August 1, 2026 18:10

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.30%. Comparing base (25686fd) to head (f959bf0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2123      +/-   ##
==========================================
+ Coverage   87.27%   87.30%   +0.03%     
==========================================
  Files         138      138              
  Lines        5507     5508       +1     
==========================================
+ Hits         4806     4809       +3     
+ Misses        421      419       -2     
  Partials      280      280              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe
TerryHowe merged commit c61fb26 into oras-project:main Aug 1, 2026
9 checks passed
@TerryHowe

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should logging also use OutOrStdout ErrOrStderr

2 participants