This is to be attached to our logging interface. Useful at the end of dataset preparation, to tell user how many errors are there.
| 37 | |
| 38 | |
| 39 | class ErrorCountHandler(logging.Handler): |
| 40 | """ |
| 41 | This is to be attached to our logging interface. |
| 42 | Useful at the end of dataset preparation, to tell user how many errors are there. |
| 43 | """ |
| 44 | |
| 45 | def __init__(self, level=logging.NOTSET): |
| 46 | super().__init__(level) |
| 47 | self.error_count = 0 |
| 48 | |
| 49 | def emit(self, record): |
| 50 | if record.levelno == logging.ERROR: |
| 51 | self.error_count += 1 |
| 52 | |
| 53 | |
| 54 | class DatasetPreparer: |