Воспользуйтесь logging.exception


мусор logging