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

Integrating structlog with logot #596

Closed
etianen opened this issue Feb 13, 2024 · 3 comments
Closed

Integrating structlog with logot #596

etianen opened this issue Feb 13, 2024 · 3 comments

Comments

@etianen
Copy link

etianen commented Feb 13, 2024

Hello! 👋 I've just released logot, a log testing library. One of it's things is the ability to integrate with 3rd-party logging frameworks, and it launched with support for loguru.

I've since had a couple of people ask whether it could support structlog, with someone offering to author a PR. I was hoping you could answer a couple of questions, as I've not used structlog myself. 🙏

What is a good version range to support? I was thinking v23-24, since that covers a year of releases. However, your security policy seems to indicate some very generous backwards compatibility guarantees, so I was wondering about going with an uncapped supported version?

How can I avoid stepping on the toes of your built-in testing tools? You've included some nice built-in testing tools, very comparable to caplog and assertLogs. The assertions provided by logot are higher level, with some nifty things like:

Hopefully that would be seen as an extension to what you're offering, for cases where more complex log assertions are helpful. 🙇

Are you happy for me to link to this from your third party extensions wiki page? Kinda the same question as above. Given the overlap with your own testing tools, are you happy for me to link out to it?

Any integration tips? It looks like a pretty straightforward integration using a custom log processor. One thing I'm struggling to find in your docs is a way of removing a log processor once added. In other words a way of adding a log capturer at the start of a test run, and removing it at the end, restoring the previous log configuration.

Thank you! ❤️

@etianen
Copy link
Author

etianen commented Feb 13, 2024

I already answered my last question by looking at the source code of capture_logs 🙇

@hynek
Copy link
Owner

hynek commented Feb 14, 2024

What is a good version range to support? I was thinking v23-24, since that covers a year of releases. However, your security policy seems to indicate some very generous backwards compatibility guarantees, so I was wondering about going with an uncapped supported version?

I don't think it's useful to make abstract claims like this, as you've noted yourself. I would try to check if the original testing helpers from 20.2.0 work like the current release for you intents and purposes and call it a day.

How can I avoid stepping on the toes of your built-in testing tools? You've included some nice built-in testing tools, very comparable to caplog and assertLogs. The assertions provided by logot are higher level, with some nifty things like:

Hopefully that would be seen as an extension to what you're offering, for cases where more complex log assertions are helpful. 🙇

What exactly do you mean by my toes here? 😅 If you mean ego-wise, I can assure you I'm extremely happy about any project that improves a) structlog and b) testing in general. ;)

I only haven't added more high-level tools to structlog proper because quite frankly I don't want to maintain them. But internally, I have similar helpers like you're building.

Are you happy for me to link to this from your third party extensions wiki page? Kinda the same question as above. Given the overlap with your own testing tools, are you happy for me to link out to it?

Please, by any means!

Any integration tips? It looks like a pretty straightforward integration using a custom log processor. One thing I'm struggling to find in your docs is a way of removing a log processor once added. In other words a way of adding a log capturer at the start of a test run, and removing it at the end, restoring the previous log configuration.

I already answered my last question by looking at the source code of capture_logs 🙇

AFAICT this was the only technical question so you should be unblocked on technicalities? 😅

@etianen
Copy link
Author

etianen commented Feb 14, 2024

Thanks! Regarding your toes 🦶, I wanted to make sure you didn't have any plans of your own to expand the structlog testing tools, or held some strong opinion that what you'd already provided was already good enough for anyone! I've seen a few cases of this sort of thing being shot down before!

Thanks for the version range suggestion, and for your time and encouragement! I'll close this now with a 🖖.

@etianen etianen closed this as completed Feb 14, 2024
etianen pushed a commit to etianen/logot that referenced this issue Feb 17, 2024
- Adds `StructlogCapturer` and related docs. 

Follows `loguru` extension structure, borrowing inspiration from the
structlog testing tools. I've matched the suggested version range in
hynek/structlog#596.

Closes #108
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

No branches or pull requests

2 participants