"Use % formatting in logging functions and pass the % parameters as arguments"


Can anybody give a judgement on this? If the .format is preferred,
then we'll look into changing the landscape.io settings.

As far as I can tell from the Python 2 logging docs [1] at least, the following is indeed the preferred approach:

logging.info("Some message with a param: %s", param)

One of the reasons is that the string representation of param does not need to be evaluated if the framework can determine that info logging is not enabled - this differs from using format, where the string has to be calculated irrespective of whether it is ever emitted.



[1] https://docs.python.org/2/library/logging.html

Reply via email to