Skip to content

Conversation

@charmingduchess
Copy link
Contributor

@charmingduchess charmingduchess commented Aug 19, 2025

Add optional json logger using structlog.

@aaronfriedman6
Copy link
Contributor

When I just log without mocking, though, I do see the correct value being printed

I think you should use the real thing. In my opinion it only needs to be mocked when testing other methods that happen to use logging, not when logging is the point of the test.

@charmingduchess
Copy link
Contributor Author

The tests that are failing are from a completely different part of the code, and are also broken in main. I'm going to make a ticket for fixing them and not have them block this work.

@yossariano
Copy link
Contributor

The tests that are failing are from a completely different part of the code, and are also broken in main. I'm going to make a ticket for fixing them and not have them block this work.

I wanted to see if I could fix the failing test but the failure isn't reproducing for me on the main branch- or your branch checked out locally, for that matter. I re-ran the test in GH and an additional test failed. Mysterious.

I agree with your assessment that this failure isn't caused by your change- Tentatively approving this so we can unblock experimenting with structured logging in our python apps

Copy link
Contributor

@yossariano yossariano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in our 1:1- I'm interested in seeing how well this plays with cloudwatch logging. But I don't think if there's a problem there that the fix will be needed in this package.

processors=[
structlog.processors.add_log_level,
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.EventRenamer("message"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully recall why I changed this from the default event to message in eReading- I think the change is fine but we should keep it in mind in case there's anything that expects event as a field in structured logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that the winston json logging sets the first param as message in the json object, so this would ensure parity with that.

@charmingduchess charmingduchess merged commit 5c84c27 into main Aug 28, 2025
2 of 4 checks passed
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.

4 participants