Skip to content

[Cleanup] Replace bare print() with logger and use specific exception types#2228

Open
Lidang-Jiang wants to merge 1 commit intovllm-project:mainfrom
Lidang-Jiang:cleanup/replace-print-with-logger-and-specific-exceptions
Open

[Cleanup] Replace bare print() with logger and use specific exception types#2228
Lidang-Jiang wants to merge 1 commit intovllm-project:mainfrom
Lidang-Jiang:cleanup/replace-print-with-logger-and-specific-exceptions

Conversation

@Lidang-Jiang
Copy link
Contributor

Summary

Replace 8 bare print() calls in production code with proper logger calls (5 files), and replace 2 generic raise Exception with specific exception types (2 files).

Motivation: Bare print() bypasses vLLM's logging configuration (log levels, formatters, handlers). Generic Exception prevents callers from catching specific error types.

Benchmark code and intentional file I/O print(file=f) calls are left unchanged.

Changes

Exception types (2 files)

File Change
diffusion/diffusion_engine.py:102 raise Exception(...)raise RuntimeError(...)
model_executor/models/cosyvoice3/utils.py:183 raise Exception(...)raise TypeError(...)

print() → logger (5 files, 8 calls)

File Change
diffusion/attention/backends/ring/ring_utils.py print(f"ERROR...")logger.error(...)
diffusion/models/dreamid_omni/fusion.py print("Warning:...")logger.warning(...)
diffusion/models/hunyuan_image_3/hunyuan_image_3_tokenizer.py print(vars)logger.debug(...)
diffusion/models/hunyuan_image_3/hunyuan_image_3_transformer.py print(f"Skipping...")logger.warning(...)
model_executor/models/qwen3_tts/tokenizer_25hz/vq/core_vq.py print(f"VQ expire...")logger.info(...)

All new loggers use from vllm.logger import init_logger consistent with the rest of the codebase. Lazy %s formatting is used instead of f-strings.

Test plan

  • ruff check passes on all 7 modified files
  • ruff format --check passes on all 7 modified files
  • All pre-commit hooks pass
  • No functional logic changed — only logging and exception type improvements

🤖 Generated with Claude Code

… types

Replace 8 bare print() calls in production code with proper logger calls
(5 files), and replace 2 generic `raise Exception` with RuntimeError/TypeError
(2 files). Benchmark code and intentional file I/O print(file=f) calls are
left unchanged.

Motivation: Bare print() bypasses vLLM's logging configuration (log levels,
formatters, handlers). Bare Exception prevents callers from catching specific
error types.

Signed-off-by: Lidang Jiang <lidangjiang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant