Skip to content

Avoid duplicate logs#3509

Closed
kichristensen wants to merge 2 commits intogetporter:mainfrom
kichristensen:avoidDuplicateLogs
Closed

Avoid duplicate logs#3509
kichristensen wants to merge 2 commits intogetporter:mainfrom
kichristensen:avoidDuplicateLogs

Conversation

@kichristensen
Copy link
Contributor

What does this change

Give a summary of the change, and how it affects end-users. It's okay to copy/paste your commit messages.

For example if it introduces a new command or modifies a commands output, give an example of you running the command and showing real output here.

What issue does it fix

Closes # (issue)

If there is not an existing issue, please make sure we have context on why this change is needed. See our Contributing Guide for examples of when an existing issue isn't necessary.

Notes for the reviewer

Put any questions or notes for the reviewer here.

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

@kichristensen kichristensen force-pushed the avoidDuplicateLogs branch 3 times, most recently from cd965cc to 7b69735 Compare December 2, 2025 22:25
Introduce ErrorTracer and ErrorLogger interfaces to
prevent duplicate error logs in console output. The
RecordError methods only record to spans while Error
methods both log to console and record to spans.

Changes:
- Add ErrorTracer interface with RecordError methods
- Add ErrorLogger interface with Error methods
- Implement RecordError to only write to spans
- Refactor Error to delegate to RecordError
- Add helper functions GetTracer and GetLogger
- Add comprehensive test coverage for new behavior

This resolves duplicate error logging when errors are
propagated up the call stack, as intermediate functions
can use RecordError while top-level handlers use Error.

Signed-off-by: Kim Christensen <[email protected]>
commands

Update all installation command handlers to explicitly log
errors at the top level using log.Error(). This ensures errors
are logged to console exactly once at the command handler level,
preventing duplicate error messages.

Changes:
- Add tracing package import
- Update 9 command handlers (list, show, apply, delete, runs
  list, install, upgrade, invoke, uninstall)
- Add explicit error logging in RunE functions
- Keep PreRunE unchanged for validation only

This is part of Phase 3 (Command Handler Updates) of the
centralized error logging implementation plan.

Signed-off-by: Kim Christensen <[email protected]>

fixup

Signed-off-by: Kim Christensen <[email protected]>
@kichristensen kichristensen deleted the avoidDuplicateLogs branch March 25, 2026 21:10
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.

1 participant