Open Julian-O opened 5 years ago
It seems that the original motivation was explained in #5 but i agree that it will be nice have it in the README.
Also, i don't understand the example in the README. Afaik extra
keyword is not used for variable data but for the logging.Formatter
.
>>> import logging
>>> logging.error("Hello {world}", extra={"world":"Earth", "color": "blue"})
ERROR:root:Hello {world}
>>> import logging
>>> logging.basicConfig(format="%(color)s - %(message)s")
>>> logging.error("Hello {world}", extra={"world":"Earth", "color": "blue"})
blue - Hello {world}
@fpuga that is correct.
We use two custom formatters. One we wrote for console output, that will format
the log message using those extra arguments. The other from pythonjsonlogger
will add the extra
dict to the logged JSON; we use it for the logs we send to our logging aggregation system (we use Loggly).
I agree the README could be made clearer there.
@Julian-O a paragraph on motivation was added to the README
in https://github.com/globality-corp/flake8-logging-format/pull/19
Thanks @afallou, it's more clear now.
Since it is clear now that extra
dict is only used for formatter, please also update the example. It could cause confusion.
Has caused confusion. Just spent half an hour trying to figure out why the variables weren't being output.
The README.md currently says:
However, if doesn't explain why this rigor is important. It is easy to dismiss this: "A foolish consistency is the hobgoblin of little minds."
I would add a few paragraphs explaining why this practice should be adopted.
e.g.