def emit(self, record): if hasattr(record, "task_id"): db = Database() db.add_error(record.msg, int(record.task_id))