[PR #25773] refactor: replace print statements with proper logging #31199

Closed
opened 2026-02-21 20:49:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/25773

State: closed
Merged: Yes


Summary

This PR replaces direct print() statements throughout the codebase with proper logging using the Python logging module, ensuring all output is properly logged and can be controlled through logging configuration.

Closes #25772

Changes Made

  • Ruff Configuration: Added T201 rule to detect print statements, with exceptions for CLI commands and tests
  • Logging Implementation: Replaced print() calls with appropriate logger methods (info, warning, debug)

Files Modified

  • api/.ruff.toml: Added T201 rule with appropriate exceptions
  • api/core/ops/weave_trace/weave_trace.py: Use logger.info for login success message
  • api/core/rag/datasource/vdb/oceanbase/oceanbase_vector.py: Use logger.warning for invalid JSON
  • api/core/rag/datasource/vdb/oracle/oraclevector.py: Use logger.exception for insert failures
  • api/core/rag/datasource/vdb/relyt/relyt_vector.py: Use logger.exception for delete failures
  • api/core/rag/datasource/vdb/tidb_vector/tidb_vector.py: Use logger.exception for delete failures
  • api/services/plugin/data_migration.py: Use logger.debug for debugging information
**Original Pull Request:** https://github.com/langgenius/dify/pull/25773 **State:** closed **Merged:** Yes --- ## Summary This PR replaces direct `print()` statements throughout the codebase with proper logging using the Python logging module, ensuring all output is properly logged and can be controlled through logging configuration. Closes #25772 ## Changes Made - **Ruff Configuration**: Added T201 rule to detect print statements, with exceptions for CLI commands and tests - **Logging Implementation**: Replaced print() calls with appropriate logger methods (info, warning, debug) ### Files Modified - `api/.ruff.toml`: Added T201 rule with appropriate exceptions - `api/core/ops/weave_trace/weave_trace.py`: Use logger.info for login success message - `api/core/rag/datasource/vdb/oceanbase/oceanbase_vector.py`: Use logger.warning for invalid JSON - `api/core/rag/datasource/vdb/oracle/oraclevector.py`: Use logger.exception for insert failures - `api/core/rag/datasource/vdb/relyt/relyt_vector.py`: Use logger.exception for delete failures - `api/core/rag/datasource/vdb/tidb_vector/tidb_vector.py`: Use logger.exception for delete failures - `api/services/plugin/data_migration.py`: Use logger.debug for debugging information
yindo added the pull-request label 2026-02-21 20:49:01 -05:00
yindo closed this issue 2026-02-21 20:49:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31199