python-hyper / hpack

HTTP/2 Header Encoding for Python
https://hpack.readthedocs.io/en/latest/
MIT License
72 stars 32 forks source link

Use trace log level instead of debug #273

Open merlinz01 opened 1 month ago

merlinz01 commented 1 month ago

I added a Hypercorn server to my application for an API. I still want to be able to debug my own code, but if I enable the debug logging level, it results in lots of irrelevant (for me) debug-level encoding/decoding logs from hpack.hpack. IMHO, that sort of logs should be at a lower level yet than debug.

Here's my general philosophy of log levels:

Error: Something went wrong and needs to be fixed. Warning: The user did something invalid. Or you shouldn't do thus-and-so for best results. Info: Something routine and occasional happened (like a new connection). This is what to look for to see if things are running OK in production. Debug: This is relevant details about how the program is flowing. Some lower-level task returned successfully, or a risky function is about to be called, or a frequent routine operation is in the works, or the user's ID is johndoe. Trace: Lots of nitty-gritty details in case we can't nail that bug.

The logging module doesn't define a trace level but you can do it by simply stating TRACE = 5 and calling log.log(TRACE, ...). I can open a PR to do this if you are OK with the idea.