-
-
Notifications
You must be signed in to change notification settings - Fork 61
feat: make rich logger optional #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@YuriiMotov
YuriiMotov
Jul 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove logger.addHandler(rich_handler)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed rich handler because, as a part of https://github.com/Textualize/rich it makes assumptions about output being console. In no way does this compromise logging capabilities when output is redirected to file.
Logging handlers and formatters can be set by the outside code, e.g. the way you set logging config for uvicorn here: https://github.com/fastapi/fastapi-cli/blob/main/src/fastapi_cli/cli.py#L180
Here is how I set logging config via a single yaml
Do NOT use rich logger when fastapi cli output is redirected or piped.
For the output to a terminal the behavior is unchanged.