encode / uvicorn

An ASGI web server, for Python. 🦄
https://www.uvicorn.org/
BSD 3-Clause "New" or "Revised" License
8.57k stars 745 forks source link

Add a logger config file example and how to use it #2260

Closed bijela-gora closed 8 months ago

bijela-gora commented 8 months ago

Summary

Hello,

Thank you for paying attention to this.

I've added an example how to use logger config file and how it can look like. The changes should resolve #491

Thank you in advance for a review.

Checklist

New section screenshot

image

bijela-gora commented 8 months ago

@Kludex @tomchristie hi,

I'd appreciate it if you could review this PR. Thank you in advance.

Sorry, for mentioning you. Details and a screenshot in the first PR comment.

bijela-gora commented 8 months ago

Thank you!

What else should be done to squash merge this? I don't have a merge button.

Kludex commented 8 months ago

I don't think we should be recommending any third-party package here.

I also think we need a whole section about logging.

Kludex commented 8 months ago
bijela-gora commented 8 months ago

@Kludex

Hello, thank you for the review.

I decided to take structured login as an example because it's widely adopted, it's useful and valuable. I fully understand and accept your desire not to recommend any third-party packages, even though I don't have the same experience in open source as you. For me it will be even more interesting to use Python native abilities to implement structured logging.

During preparation of the section about --log-config parameter, I felt tendency to write a lot more then is written, to show the whole example. But then I realized that it looks like a tutorial about logging, and not a short example. So, I stopped myself. This PR was created just to close the #491 issue.

If you'll allow me, I can only speak for myself, I was looking for exactly this kind of section. About structural logging. It is now a de-facto industry standard. I agree that there is still a lot to be said about logging. But I also believe that even such a small improvement will be useful.

So, before I go on, I want to ask you if you will accept my PR if I remove the third-party package recommendation?

By the way, I checked the source code of python-json-logger and it looks small and quite simple, means easily auditable.