You can write your own formatter:
from datetime import timedelta import logging import time class ElapsedFormatter(): def __init__(self): self.start_time = time.time() def format(self, record): elapsed_seconds = record.created - self.start_time
Your question relates to the elapsed time from the "beginning of the program", as well as to the "creation of the registrar", which can mean different things.
This will measure the time elapsed since the CustomFormatter , which you could close when the program started or when creating the log.
Jeremy allen
source share