Skip to content

fix: correct stderr logger level from ERROR to WARNING#3797

Open
gambletan wants to merge 1 commit intolm-sys:mainfrom
gambletan:fix-stderr-logging-level
Open

fix: correct stderr logger level from ERROR to WARNING#3797
gambletan wants to merge 1 commit intolm-sys:mainfrom
gambletan:fix-stderr-logging-level

Conversation

@gambletan
Copy link

Summary

  • Fixed stderr_logger level in build_logger() from ERROR to INFO (matching stdout_logger)
  • Fixed StreamToLogger for stderr from logging.ERROR to logging.WARNING to properly reflect stderr's typical content
  • Previously, stderr output was being logged at ERROR level, which incorrectly elevated warnings and informational stderr messages to errors

Details

In fastchat/utils.py, the build_logger() function sets up stream redirection for both stdout and stderr. The stdout logger correctly uses INFO level, but stderr was using ERROR for both the logger level and the StreamToLogger level.

This means:

  1. Any stderr output (including normal warnings from libraries like transformers, torch, etc.) gets logged as ERROR
  2. The stderr_logger.setLevel(logging.ERROR) filters out anything below ERROR, so WARNING-level messages from stderr would be silently dropped

The fix:

  • stderr_logger.setLevel(logging.INFO) — matches stdout_logger, allows all messages through
  • StreamToLogger(stderr_logger, logging.WARNING) — logs stderr at WARNING level, which is the appropriate severity for stderr content

Test plan

  • Verify stderr messages from libraries (e.g., transformers deprecation warnings) now appear in logs at WARNING level instead of ERROR
  • Verify stdout logging behavior is unchanged
  • Run python -c "from fastchat.utils import build_logger; logger = build_logger('test', 'test.log')" to confirm no regressions

🤖 Generated with Claude Code

The stderr StreamToLogger was set to logging.ERROR, which means
stderr output was logged at ERROR level. This is incorrect because
stderr contains warnings and informational messages too. Changed to
WARNING level which better matches stderr's typical content.

Also set stderr_logger base level to INFO (matching stdout_logger)
so that WARNING-level messages are not filtered out.
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