Skip to content

SPLIT: Original PR split into focused PRs #4485a and #4485b#4485

Closed
cidrblock wants to merge 11 commits intoansible:mainfrom
cidrblock:feat/cleanup-unused-loggers
Closed

SPLIT: Original PR split into focused PRs #4485a and #4485b#4485
cidrblock wants to merge 11 commits intoansible:mainfrom
cidrblock:feat/cleanup-unused-loggers

Conversation

@cidrblock
Copy link
Copy Markdown

@cidrblock cidrblock commented Jul 28, 2025

🔄 This PR has been split for better review

This original PR contained mixed concerns and has been split into two focused PRs:

📦 PR #4485a: Pure Cleanup

Branch: feat/cleanup-unused-loggers-only
Scope: Remove unused LOG = logging.getLogger(__name__) definitions
Status: Ready for review
URL: cidrblock/molecule@main...feat/cleanup-unused-loggers-only

🏗️ PR #4485b: Dynamic Logger Architecture

Branch: feat/dynamic-logger-properties
Scope: Convert cached loggers to dynamic @property pattern + Config enhancements
Status: Ready for review
URL: cidrblock/molecule@main...feat/dynamic-logger-properties

🎯 Split Benefits

  • Focused review: Cleanup vs. architectural changes
  • Independent merging: Cleanup can merge first
  • Clear separation: Pure removal vs. enhanced functionality
  • Better commit organization: Logical grouping by purpose

📋 Review Strategy

  1. Review #4485a first (simple cleanup, low risk)
  2. Merge #4485a to reduce codebase noise
  3. Review #4485b (architectural improvements)
  4. Merge #4485b for enhanced logging

🔧 Technical Split Details

Cleanup-only commits (→ #4485a):

  • cleanup: remove unused logger definitions from logger.py, syntax.py, and state.py
  • cleanup: remove unused logger definitions from 18+ files
  • cleanup: remove final unused LOG definition from base.py

Architectural commits (→ #4485b):

  • refactor: convert _log to property in dependency, provisioner, verifier and command classes
  • style: remove redundant __init__ methods
  • feat: add step context to command base logger calls
  • feat: add scenario context to config file modification warning
  • refactor: add reusable _log property to Config class
  • refactor: convert all Config logging to scenario-aware logging

This PR will be closed once the split PRs are merged.

Command classes will be handled separately with base.Base consolidation.
This PR now focuses only on dependency, provisioner, and verifier classes.
- Add step context to scenario discovery logging (discovery)
- Add step context to prerun logging (prerun)
- Add step context to reset scenario logging (reset)
- Add step context to error cleanup logging (action/cleanup)
- Add step context to default scenario fallback warning (subcommand)
- Replace LOG.warning with scenario logger in Config.state property
- Add step context 'config' for configuration-related warnings
- Import logger module for scenario context support
…and state.py

- Remove unused LOG = logging.getLogger(__name__) definitions
- Remove corresponding logging imports where no longer needed
- Fix Callable import in state.py to use collections.abc
- Remove unused LOG = logging.getLogger(__name__) from command modules
- Remove unused LOG definitions from dependency, driver, and provisioner modules
- Remove corresponding logging imports where no longer needed
- Clean up state.py, platforms.py, verifier/testinfra.py and others
- All pre-commit checks passing after cleanup
- Remove unused LOG = logging.getLogger(__name__) from command/base.py
- Keep logging import as it's still used in one place (line 137)
- All LOG definitions are now used (verified 6 remaining files)
@cidrblock cidrblock force-pushed the feat/cleanup-unused-loggers branch from 8ed3ec4 to 35ba18c Compare July 28, 2025 16:52
@cidrblock cidrblock marked this pull request as draft July 28, 2025 16:55
@cidrblock cidrblock marked this pull request as ready for review July 28, 2025 19:35
Remove test file changes that belong in other PRs:
- test_shell.py: Scenario context testing belongs in dependency logger fix PR
- test_ansi_output.py: Environment detection testing was deferred

Keep this PR focused only on removing unused logger definitions.
@cidrblock cidrblock force-pushed the feat/cleanup-unused-loggers branch from 4b7005b to 1d8c1d2 Compare July 28, 2025 19:41
@cidrblock cidrblock changed the title Remove unused logger definitions to prevent misuse refactor: implement dynamic logger context and cleanup unused loggers Convert cached loggers to dynamic properties for accurate scenario/step context and remove unused logger definitions to prevent context-less logging. Jul 28, 2025
@cidrblock cidrblock changed the title refactor: implement dynamic logger context and cleanup unused loggers Convert cached loggers to dynamic properties for accurate scenario/step context and remove unused logger definitions to prevent context-less logging. refactor: Additional logger cleanup Jul 28, 2025
Add @Property _log method to Config class that provides scenario-aware
logging with 'config' step context. Update existing logger call in
state property to use self._log instead of creating ad-hoc logger.

This enables other Config methods to use self._log for consistent
scenario and step context in log messages.
Complete conversion of Config class logging to use scenario context:

- _validate(): Use hardcoded scenario logger during validation
- _get_driver_name(): Use self._log for driver warnings
- collection(): Use self._log for galaxy.yml validation warnings

Remove unused module-level logger (LOG) and import since all
logging now uses scenario-aware loggers with proper step context.

Benefits:
- All Config logging now includes scenario and step information
- Consistent logging pattern throughout Config class
- Eliminates context-less logging in Config operations
@cidrblock cidrblock changed the title refactor: Additional logger cleanup SPLIT: Original PR split into focused PRs #4485a and #4485b Jul 28, 2025
@cidrblock
Copy link
Copy Markdown
Author

Closing this PR in favor of clean, focused PRs with proper dependency ordering against upstream main.

Replaced by:

  • PR #TBD: cleanup-unused-loggers (independent, can merge first)
  • PR #TBD: dynamic-logger-properties (depends on cleanup PR)

This approach provides cleaner commit history and proper review dependency chain.

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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant