Skip to content

refactor(logging): replace print statements with structured logging#73

Merged
eaglei15 merged 1 commit into
GenAI-Security-Project:v0.2from
emmanuelgjr:refactor/16-structured-logging
Apr 20, 2026
Merged

refactor(logging): replace print statements with structured logging#73
eaglei15 merged 1 commit into
GenAI-Security-Project:v0.2from
emmanuelgjr:refactor/16-structured-logging

Conversation

@emmanuelgjr

Copy link
Copy Markdown
Contributor

Summary

  • Replace all 21 print() statements across src/cli.py, src/main.py, and src/controllers/cli_controller.py with Python's logging module using module-level loggers
  • Use lazy %s formatting instead of f-strings per CONTRIBUTING.md conventions
  • Configure logging.basicConfig() in CLI entrypoint with timestamp format and --verbose flag support

Additional fixes

  • Fix --verbose flag to set DEBUG level (was incorrectly setting INFO)
  • Remove duplicate from ..models.scoring import calculate_completeness_score import
  • Replace remaining f-string log calls with lazy %s formatting for consistency
  • Fix indentation inconsistency on final else block

Log level mapping

Level Use Case
DEBUG Static asset copy details, verbose output
INFO Generation progress, results, scores, reports
WARNING Schema validation errors, missing assets, HTML report failures
ERROR SBOM generation failures

Test plan

  • All 29 existing tests pass (pytest with --cov=src)
  • Run CLI: python -m src.cli "microsoft/DialoGPT-medium" — verify structured log output
  • Run CLI with verbose: python -m src.cli "microsoft/DialoGPT-medium" --verbose — verify DEBUG messages appear
  • Run web server: python -m uvicorn src.main:app — verify startup log message

Closes #16

Generated with Claude Code

Replace all print() calls across CLI and web entry points with Python's
logging module using module-level loggers and lazy % formatting, as
recommended in CONTRIBUTING.md. Configure logging.basicConfig in CLI
entrypoint with --verbose flag setting DEBUG level. Also fix duplicate
import of calculate_completeness_score and correct --verbose to set
DEBUG (was INFO).

Closes GenAI-Security-Project#16

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eaglei15
eaglei15 merged commit 4df60bf into GenAI-Security-Project:v0.2 Apr 20, 2026
1 check passed
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.

2 participants