Always use the standardized logging pattern with module-level loggers instead of print statements or direct logging calls. This ensures consistent logging behavior, proper log level control, and better debugging capabilities across the codebase.
Always use the standardized logging pattern with module-level loggers instead of print statements or direct logging calls. This ensures consistent logging behavior, proper log level control, and better debugging capabilities across the codebase.
The standard pattern is:
import logging
logger = logging.getLogger(__name__)
logger.info("Your message here")
logger.warning("Warning message")
logger.debug("Debug info", exc_info=True) # Include exception info when relevant
Replace print statements with appropriate log levels:
logger.error()
or logger.warning()
instead of print(e)
for exceptionslogger.info()
for general informationlogger.debug()
for detailed debugging informationIn modules where the dspy logger isn’t available (like dsp folder), follow the same pattern by creating a module-level logger. This maintains consistency and allows proper log level configuration across the entire application.
Enter the URL of a public GitHub repository