A collection of my favorite Python debugging options — Print import time
print(time.asctime(),'debugging ...') Output: Sat Jul 4 13:45:52 2020 debugging ... Logging Basic import logging
logging.basicConfig(filename = 'a.log')
log = logging.getLogger()
log.error('Some error') cat a.log: ERROR:root:Some error More Config import logging # DEBUG, INFO, WARNING, ERROR, CRITICAL
log_level = logging.INFO
logging.basicConfig(filename = 'b.log',
level=log_level,
filemode='w', # or 'a'
format='%(asctime)s %(levelname)s: %(message)s',
)