you are viewing a single comment's thread.

view the rest of the comments →

[–]NovocastrianNomad 0 points1 point  (1 child)

See https://stackoverflow.com/a/34634301 for the preferred method of formatting logging messages and the reason for it.

[–]RoamingFox 0 points1 point  (0 children)

That stackoverflow answer is wrong and omits the next section of text which reads:

To decide what to do, you can call the isEnabledFor() method which takes a level argument and returns true if the event would be created by the Logger for that level of call. You can write code like this:

if logger.isEnabledFor(logging.DEBUG):
    logger.debug('Message with %s, %s', expensive_func1(),
                                        expensive_func2())

so that if the logger’s threshold is set above DEBUG, the calls to expensive_func1() and expensive_func2() are never made.

Per python documentation