How do you log in your projects?

Marco Sulla Marco.Sulla.Python at gmail.com
Thu Feb 10 16:45:54 EST 2022


On Wed, 9 Feb 2022 at 20:40, Martin Di Paola <martinp.dipaola at gmail.com> wrote:
>
> If the logs are meant to be read by my users I log high level messages,
> specially before parts that can take a while (like the classic
> "Loading...").

? Logs are not intended to be read by end users. Logs are primarily
used to understand what the code is doing in a production environment.
They could also be used to gather metrics data.

Why should you log to give a message instead of simply using a print?

> For exceptions I print the message but not the traceback.

Why? Traceback is vital to understand what and where the problem is. I
think you're confusing logs with messages. The stack trace can be
logged (I would say must), but the end user generally sees a vague
message with some hints, unless the program is used internally only.


More information about the Python-list mailing list