def format(self, record):
    elapsed_seconds = record.created - self.start_time
elapsed = timedelta(seconds=elapsed_seconds)
return '{} {}'.format(elapsed, record.getMessage())
handler = logging.StreamHandler()
handler.setFormatter(ElapsedFormatter())
logging.getLogger().addHandler(handler)
log = logging.getLogger('test')
log.error('Message 1')
time.sleep(5)
log.error('Message 2')
Python logging time since start of program