Answer the question
In order to leave comments, you need to log in
Not a trivial example of the Logger library in python?
I would like to study the code that implements the logger library in python. Not in one file by a simple example. And it is included in several application modules, with a logger conf setting to handle various errors (for example, running out of disk space). You need to see how people with experience use it. I repeat, trivial examples are not of interest. Any project on github will do just fine.
Answer the question
In order to leave comments, you need to log in
A few years ago I (apparently like you) came to believe in logging. It's not for nothing that there are such wild and deep settings: there are formatters, handlers, and some kind of filters. And I thought: cool programmers use all this, and I beg in the back of the market.
And since then I began to configure all conceivable and inconceivable logging settings. All the errors I had were in the corresponding error files. Also, there was a log with debug information. All this was grouped by files. The debug was formatted with one formatter, the erroneous log was formatted with another formatter, more detailed. And all this grew, blossomed and smelled.
Reality was cruel. All these formatters turned out to be a waste - it became more difficult to hack logs. Separate files with debugs and errors turned out to be abuse - after all, it's easier to grep at the log level ( | grep ERROR). In a pile of log files - the devil will break his leg. And in general, the logs almost always turned out to be unnecessary - errors fly to Sentry, and statistics are collected by other mechanisms (prometheus). And the rotation and archiving of logs was done by devops.
And here are the good practices that I took out:
1. Take loguru, which literally does not need settings:
from loguru import logger
...
# Где-то настроил sink-файл (либо будет только stdout)
...
logger.debug("hello")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question