Skip to content

feat: replace print() calls with Python logging module#4

Open
Aditya8840 wants to merge 1 commit intomainfrom
feat/issue-2
Open

feat: replace print() calls with Python logging module#4
Aditya8840 wants to merge 1 commit intomainfrom
feat/issue-2

Conversation

@Aditya8840
Copy link
Copy Markdown
Owner

Summary

Closes #2

  • Replace all 11 print() calls across agent.py and main.py with properly-leveled logging.getLogger("droidpilot") calls (INFO, WARNING, ERROR, DEBUG)
  • Add _setup_logging() helper in main.py with clean format (no timestamps for TTY, timestamps for file/verbose output)
  • Add --verbose (-v) and --quiet (-q) mutually exclusive CLI flags to control output verbosity

Changes

droidpilot/main.py

  • Added _setup_logging(verbose, quiet) helper configuring the droidpilot logger
  • Added -v/--verbose flag (DEBUG level + timestamps) and -q/--quiet flag (WARNING level only)
  • Replaced print(..., file=sys.stderr) error output with logger.error()
  • Replaced print() status messages with logger.info()
  • Added return type hint to main()

droidpilot/agent.py

  • Added logging import and module-level logger = logging.getLogger("droidpilot")
  • Replaced all print() calls with appropriate severity levels:
    • logger.info() for device info, task, step progress, and completion
    • logger.warning() for UI read failures and missing actions
    • logger.debug() for action result details

Test plan

  • Run droidpilot "test" — should show INFO-level output without timestamps
  • Run droidpilot -v "test" — should show DEBUG-level output with timestamps
  • Run droidpilot -q "test" — should only show warnings and errors
  • Run droidpilot "test" 2>debug.log — log file should contain timestamps
  • Verify -v and -q are mutually exclusive (parser rejects both)

🤖 Generated with Claude Code

Replace all 11 print() calls across agent.py and main.py with proper
logging using logging.getLogger("droidpilot"). Each message is mapped
to the correct severity (INFO, WARNING, ERROR, DEBUG).

Add _setup_logging() helper in main.py that configures the droidpilot
logger with a clean format — no timestamps for TTY, timestamps when
piped to a file or in verbose mode.

Add --verbose (-v) and --quiet (-q) mutually exclusive CLI flags to
control output verbosity (DEBUG and WARNING levels respectively).

Closes #2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Replace print() calls with Python logging module

2 participants