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

Bug: Can't turn off CriticalLogMiddleware #1818

Open
mdgilene opened this issue Sep 25, 2024 · 4 comments
Open

Bug: Can't turn off CriticalLogMiddleware #1818

mdgilene opened this issue Sep 25, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@mdgilene
Copy link

mdgilene commented Sep 25, 2024

Describe the bug
There seems to be no official way to turn of this middleware by default. After looking through the code the only viable option would be to set the PYTEST_CURRENT_TEST env var even when I'm not running my tests...which just seems silly. Not being able to turn this off clutters the logs with unnecessary messages.

How to reproduce
Setup a FastStream broker and watch for "Recieved" and "Processed" messages all over the place.

Expected behavior
The ability to turn this off.

Environment
Running FastStream 0.5.23 with CPython 3.12.3 on Linux

# TODO: remove useless middleware filter
if not is_test_env():
self._middlewares = (
CriticalLogMiddleware(self.logger, log_level),
*self._middlewares,
)

@mdgilene mdgilene added the bug Something isn't working label Sep 25, 2024
@Lancetnik
Copy link
Member

@mdgilene you can't remove CriticalLogMiddleware, but you can set its' logging level to DEBUG or even lower to not to see annoying messages. This is the official way to hide them.

@Lancetnik Lancetnik added enhancement New feature or request and removed bug Something isn't working labels Sep 26, 2024
@mdgilene
Copy link
Author

mdgilene commented Sep 26, 2024

@Lancetnik As you have already noted, I guess this is more of an enhancement request than a bug then. The big glaring "TODO" right above this code seems to suggest that this definitely needs to be handled differently or be made optional entirely. At the very least, I think changing the "Received" and "Processed" logs to use a static DEBUG level instead of the globally configured level would be more inline with their purpose.

It feels like this would be fairly straight forward. I can work on a PR if you'd like?

In my case I am trying to provide a custom logger to the broker so just setting the log level doesn't seem to be viable since it would suppress the rest of the logs I do want to see.

@Lancetnik
Copy link
Member

In my case I am trying to provide a custom logger to the broker so just setting the log level doesn't seem to be viable since it would suppress the rest of the logs I do want to see.

@mdgilene it doesn't set log level to whole logger. It is just log level for service message you mentioned. So, this option can be used with custom logger as well

@Lancetnik
Copy link
Member

I think changing the "Received" and "Processed" logs to use a static DEBUG level instead of the globally configured level would be more inline with their purpose.

I am not sure about API, but you are always welcome with any PR. Even you idea will not be merged to main, we can inspire by it and implement any decision as a part of next 0.6 major

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
None yet
Development

No branches or pull requests

2 participants