Replace all `print()` statements with appropriate logging calls using Python's built-in logging module. This applies to debug output, informational messages, and error reporting. Print statements should be reserved only for direct user interaction or when logging infrastructure is not available.
Replace all print()
statements with appropriate logging calls using Python’s built-in logging module. This applies to debug output, informational messages, and error reporting. Print statements should be reserved only for direct user interaction or when logging infrastructure is not available.
Use appropriate logging levels:
logging.debug()
for debug informationlogging.info()
for general informational messageslogging.warning()
for warningslogging.error()
for error conditionsExample transformation:
# Instead of:
print(f"Error reading version in get_workflow_templates_version: {e}")
print("Single LLAMA3_8 for HiDreams")
print(mask.shape)
# Use:
logging.error(f"Error reading version in get_workflow_templates_version: {e}")
logging.info("Single LLAMA3_8 for HiDreams")
logging.debug(f"Mask shape: {mask.shape}")
This ensures consistent log formatting, proper log levels, and enables centralized log management and filtering. Remove debug print statements entirely when they’re no longer needed, and ensure you’re using Python’s standard logging
module rather than custom logging libraries.
Enter the URL of a public GitHub repository