Skip to content
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

Feature: Enhancements to logging #2043

Open
gaby opened this issue Jan 16, 2025 · 0 comments
Open

Feature: Enhancements to logging #2043

gaby opened this issue Jan 16, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@gaby
Copy link

gaby commented Jan 16, 2025

I'm currently in the process of migrating a big code base from aio-pika to faststream. The broker/amqp stuff worked out of the box first try, the biggest hurdle has been the Logger.

We have a custom global logger in the app, when we pass this to faststream we stop getting logs. I was able to hack it in place by using the logger from the subscriber callback and passing this to the main class object.

Some things that would be nice to have:

  1. When creating a broker object the log_fmt param takes a string. In reality it should take either a string or log.Formatter.

  2. Regardless of what I use as log_fmt, the level field becomes colored. This should also be a setting, since having colored logs adds weird characters. Ex broker(colors=True), default to True.

  3. There's no param for passing a logging.Filter to the broker. These are normally used for setting contextvars. Ex `broker(log_filters=MyLogFilter())'

  • My current hack for this is to convert the faststream.Logger object into a logging.Logger then apply the filter before starting the broker.
  1. When a consumer gets a message a log that says "Received" and "Processed" is printed. This uses by default message_id from the Message. There should be a way of overriding this without having to create a full custom logger. This probably should be Per Subscriber/Publisher as a param.
  • There should also be a way of disabling this
  1. Add support for passing extra logging.Handlers to the broker.

  2. The logger used by aio-pika doesn't following the formatting from the faststream one. The logs look out of place.

@gaby gaby added the enhancement New feature or request label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant