-
Notifications
You must be signed in to change notification settings - Fork 16
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
faust hijacks console output #36
Comments
The format of logs is a product of Lines 74 to 76 in 030d69f
Regarding why print statements are getting hijacked, I took a look in Line 126 in 030d69f
override_logging: bool = False , then the print statements worked as they typically would. I'll look into this further.
All logging is handled by |
I just ran into this as well. I'm happy to try and fix it. I took a look at the history, and that flag was added in the context of ask#46. It looks like the original author wanted to always override the root logger, but this flag was added to allow users to turn that off. Change was made here: 71e11f3. I'm not sure I agree with the original logic, but just flipping the boolean from The least breaking change I can think of is to add a The second least breaking way I can think of would be to change the type of Something like this, maybe:
It'd be annoying because you'd have to pass in some kind of config that you might not need? What might make more sense would be to add a check for any existing root handlers and only override if there aren't any.
I think that would also be a breaking change, though. Let me know what you think / prefer. |
Thank you @catermelon! I'm not sure I fully understand the implications of what you're suggesting, so I'll trust your judgement in this. What I would expect to see happening is that Faust/mode prints/formats it's logging however it wants, but it should not interfere with the output of other loggers used in client apps. Or honestly even with |
Thank you so much @catermelon for finding that commit!
Agreed, this change could cause a lot of undesired chaos since we're already accustomed to logging behaving like this. Off the top of my head, I would like an option in Faust to exist so that way we can set |
Ah, okay! That would work, too. I'm happy to do that as well. |
It looks like it's already passing https://github.com/faust-streaming/faust/blob/master/faust/worker.py#L260 |
I was just about to open a Personally I'd like |
Checklist
master
branch of Faust.Steps to reproduce
I'm trying to use structlog inside a Faust app because I want to have JSON output.
However, after Faust initialization, it seems all log messages get prefixed by
[date time] [1] [WARNING]
.Running with `faust -l INFO --app main.app worker
Expected behavior
The first
logger.info
, on line 6 correctly outputs JSON:{ "event": "structlog configured", "message": "hello world" }
I expected the second
logger.info
insideread_topic
to also output JSON on a line by itself:{ "event": "Reading from topic", "topic": "test-topic" }
,Actual behavior
Instead all logging after Faust starts get prefixed by what looks to be Faust config override, for example:
[2022-11-08 15:16:17,123] [1] [WARNING] { "event": "Reading from topic", "topic": "test-topic" }
Versions
The text was updated successfully, but these errors were encountered: