Maintain high-quality logging throughout the codebase by following these best practices: 1. **Use appropriate log levels**: Reserve `debug` for detailed troubleshooting, `info` for general operational information, `warning` for potential issues, and `error`/`critical` for actual problems. Avoid excessive logging at higher levels.
Maintain high-quality logging throughout the codebase by following these best practices:
debug
for detailed troubleshooting, info
for general operational information, warning
for potential issues, and error
/critical
for actual problems. Avoid excessive logging at higher levels.
# For large object dumps or detailed diagnostics
logger.debug("Initialized config %s", config)
# Not: logger.info("Initialized config %s", config)
Remove temporary debugging logs: Debug statements with developer identifiers (e.g., "[Kourosh]"
) should be removed before merging code.
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Complex calculation result: %s",
",".join(map(str, complex_calculation())))
Avoid logging in loops unless each iteration provides unique valuable information. Consider logging summaries before/after the loop instead.
logger.warning()
(not the deprecated logger.warn()
), and use logger.exception()
for exception logging to automatically include tracebacks:
try:
# Some operation
except Exception:
logger.exception("Failed to perform operation")
# Not: logger.error("Failed: %s", str(e))
from vllm.logger import init_logger
logger = init_logger(__name__)
Enter the URL of a public GitHub repository