Skip to content

Extract status logging functions to eliminate duplication#4838

Open
khushal-winner wants to merge 1 commit intosuperfly:masterfrom
khushal-winner:extract-status-logging-functions
Open

Extract status logging functions to eliminate duplication#4838
khushal-winner wants to merge 1 commit intosuperfly:masterfrom
khushal-winner:extract-status-logging-functions

Conversation

@khushal-winner
Copy link
Copy Markdown

Change Summary

What and Why:

  • Add 7 helper functions (28 LOC) for status logging patterns
  • Replace 23 duplicate logging patterns with helper functions
  • Eliminates repetition while maintaining identical output
  • Improves maintainability with single source of truth for logging

Helper functions:

  • logMachineActionRunning/Success/Failure
  • logLeaseActionRunning/Success/Failure
  • logMachineStatus

Replaced patterns:

  • Phase A: 9 lease acquisition/clearing patterns
  • Phase B: 4 machine state/failure patterns
  • Phase C: 10 machine action patterns

How:

  • Added 7 helper functions after constants in plan.go (lines 30-57)
  • Replaced duplicate sl.LogStatus calls with appropriate helper functions
  • Verified compilation and unit tests pass
  • No logic changes, output strings remain identical

Related to:

  • Refactoring to eliminate code duplication
  • Status logging pattern consolidation

Documentation

  • Fresh Produce
  • In superfly/docs, or asked for help from docs team
  • n/a

- Add 7 helper functions (28 LOC) for status logging patterns
- Replace 23 duplicate logging patterns with helper functions
- Eliminates repetition while maintaining identical output
- Improves maintainability with single source of truth for logging

Helper functions:
- logMachineActionRunning/Success/Failure
- logLeaseActionRunning/Success/Failure
- logMachineStatus

Replaced patterns:
- Phase A: 9 lease acquisition/clearing patterns
- Phase B: 4 machine state/failure patterns
- Phase C: 10 machine action patterns

Signed-off-by: Khushal Malhotra <redmi5a3217@gmail.com>
@khushal-winner
Copy link
Copy Markdown
Author

@dangra , hi maintainers could u please take a review of these helper functions & I am open to do any changes.

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