Skip to content

fix: preserve uvicorn log levels instead of marking all stderr as ERROR#3796

Open
gambletan wants to merge 1 commit intolm-sys:mainfrom
gambletan:fix/uvicorn-log-levels
Open

fix: preserve uvicorn log levels instead of marking all stderr as ERROR#3796
gambletan wants to merge 1 commit intolm-sys:mainfrom
gambletan:fix/uvicorn-log-levels

Conversation

@gambletan
Copy link

Summary

Fixes #1292

Currently, all stderr output (including uvicorn's INFO-level messages) is captured by StreamToLogger and re-logged at ERROR level, causing confusing output like:

2023-05-17 10:56:57 | ERROR | stderr | INFO:     Started server process [19332]
2023-05-17 10:56:57 | ERROR | stderr | INFO:     Uvicorn running on http://localhost:21001

Changes in fastchat/utils.py

  • Lower stderr logger level from ERROR to INFO in build_logger() so the logger can emit messages at any level, not just ERROR+
  • Add log level detection to StreamToLogger via a _detect_log_level() method that parses standard log level prefixes (INFO:, WARNING:, ERROR:, CRITICAL:, DEBUG:) from message text and uses the detected level instead of the hardcoded default

After fix

2023-05-17 10:56:57 | INFO | stderr | INFO:     Started server process [19332]
2023-05-17 10:56:57 | INFO | stderr | INFO:     Uvicorn running on http://localhost:21001

Test plan

  • Start python3 -m fastchat.serve.controller and verify uvicorn startup messages show as INFO | stderr instead of ERROR | stderr
  • Start python3 -m fastchat.serve.openai_api_server and verify the same
  • Verify that actual errors written to stderr still appear at the correct ERROR level
  • Verify no regressions in log file output

The stderr StreamToLogger was hardcoded to log everything at ERROR level,
causing uvicorn INFO messages to appear as 'ERROR | stderr | INFO: ...'

Changes:
- Set stderr logger level to INFO instead of ERROR
- Add log level detection in StreamToLogger to parse level prefixes
  (e.g. 'INFO:', 'WARNING:') from the message text
- Use the detected level when logging, falling back to the default level

Fixes lm-sys#1292
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.

Info logs displayed as ERROR | stderr

1 participant