658 logging.exception('Error while charging omise')
659 if charge.failure_code is not None:
660 logging.warning(
661 "Omise Failure Message: {} ({})".format(662 charge.failure_message, charge.failure_code
663 )
664 )
316 )
317 except (requests.exceptions.HTTPError, requests.exceptions.InvalidURL):
318 logging.exception(
319 'Error encountered while generating resized images for event with id: {}'.format(320 speaker_id
321 )
322 )
302 speaker = Speaker.query.get(speaker_id)
303 try:
304 logging.info(
305 'Speaker image resizing tasks started for speaker with id {}'.format(306 speaker_id
307 )
308 )
275 logging.info(f'Resized images saved successfully for user with id: {user_id}')
276 except (requests.exceptions.HTTPError, requests.exceptions.InvalidURL):
277 logging.exception(
278 'Error encountered while generating resized images for user with id: {}'.format(279 user_id
280 )
281 )
252 logging.info(f'Resized images saved successfully for group with id: {group_id}')
253 except (requests.exceptions.HTTPError, requests.exceptions.InvalidURL, OSError):
254 logging.exception(
255 'Error encountered while generating resized images for group with id: {}'.format(256 group_id
257 )
258 )
Formatting the message manually before passing it to a logging
call does unnecessary work if logging in disabled. Consider using the logging
module's built-in formatting features to avoid that.
import logging, inspect
logging.basicConfig(level=logging.INFO)
logging.debug("Entered function {}".format(inspect.stack[0][3]))
import logging, inspect
logging.basicConfig(level=logging.INFO)
logging.debug("Entered function %s", inspect.stack[0][3])