Prompt
Maintain high-quality logging throughout the codebase by following these best practices:
- Use appropriate log levels: Reserve
debugfor detailed troubleshooting,infofor general operational information,warningfor potential issues, anderror/criticalfor 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. - Optimize logging performance: Guard expensive parameter computations to avoid unnecessary work when the log level is disabled:
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.
- Use standard logging methods: Use
logger.warning()(not the deprecatedlogger.warn()), and uselogger.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)) - Initialize loggers consistently: Use the project’s standard logger initialization pattern:
from vllm.logger import init_logger logger = init_logger(__name__) - Make log messages clear and actionable: Include relevant context and avoid ambiguous messages.