It might be worth noting that, for logging,
get_logger().info(
'Logger logging %s because we need to log it.'
% response['foo']['bar']
)
is the same as:
get_logger().info(
'Logger logging %s because we need to log it.',
response['foo']['bar']
)
since the debug()
, info()
, etc . methods interpret *args
as to be used for string formatting the message.
https://docs.python.org/2/library/logging.html#logging.Logger.debug
In general for long strings, ones that ought to wrap around column 80, use parentheses, taking advantage of python's built-in string joining:
deeplyNested = True
thing = 'feedback'
class Contrived(object):
def __init__(self):
if deeplyNested:
logger.info(
("Sometimes there's a lot to say in %s and you need to write"
" longer messages than what nicely fits in the 80 column"
" limit."),
thing
)