Skip to content

Replace print() calls with Python logging module #2

@Aditya8840

Description

@Aditya8840

Problem

All output goes through raw print() calls — 11 total across agent.py and main.py. There is no way to control verbosity, filter by severity, redirect output to a file, or suppress noise in automated/CI use. Error and debug output is mixed with normal status messages.

Current print() inventory:

File Line Severity Output
agent.py:116 INFO Connected to device: {serial}
agent.py:117 INFO Screen size: {w}x{h}
agent.py:118 INFO Task: {prompt}
agent.py:129 WARNING [!] Failed to read UI: {e}
agent.py:149 WARNING [!] No action returned, retrying...
agent.py:156 INFO Step {n}: {action}({args})
agent.py:160 INFO Done: {summary}
agent.py:164 DEBUG → {result}
main.py:30 ERROR Error: {e} (to stderr)
main.py:36 ERROR Error: {e} (to stderr)
main.py:39 INFO Aborted by user.

Expected behavior

  • Use logging.getLogger("droidpilot") throughout
  • Map each message to the correct severity (see table above)
  • Default to INFO level for normal use
  • Support --verbose / --quiet CLI flags to control output
  • Structured enough to pipe to a file: droidpilot "..." 2>debug.log

Suggested approach

  1. Add a _setup_logging() helper in main.py that configures the root droidpilot logger with a clean format (no timestamps for TTY, timestamps for file output)
  2. Replace each print() with the appropriate logger.info() / logger.warning() / logger.error() / logger.debug() call
  3. Add --verbose (-v) and --quiet (-q) flags to main.py
  4. Keep the step-by-step output readable — logging format should stay close to current output unless -v is passed

Files to change

  • main.py — logging setup, CLI flags
  • agent.py — replace all print() calls

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions