adamchainz/flake8-logging

Recommend deferring function calls in arguments

adamchainz opened this issue · 1 comments

Description

The Optimization section of the logging HOWTO recommends using isEnabledFor before logging a message with potentially-expensive arguments:

if logger.isEnabledFor(logging.INFO):
    logger.info('Imported %s records', qs.count())

Let’s detect log message calls that use function calls for arguments and recommend this pattern.

I think this is probably too micromanagey for a lint rule. Many function calls may be fast, like len(objs).