Flush, close possible files, and remove stdout/stderr mirroring.
(self)
| 98 | self.stdout.flush() |
| 99 | |
| 100 | def close(self) -> None: |
| 101 | """Flush, close possible files, and remove stdout/stderr mirroring.""" |
| 102 | self.flush() |
| 103 | |
| 104 | # if using multiple loggers, prevent closing in wrong order |
| 105 | if sys.stdout is self: |
| 106 | sys.stdout = self.stdout |
| 107 | if sys.stderr is self: |
| 108 | sys.stderr = self.stderr |
| 109 | |
| 110 | if self.file is not None: |
| 111 | self.file.close() |
| 112 | self.file = None |
| 113 | |
| 114 | |
| 115 | # Cache directories |