| 286 | return 1 |
| 287 | |
| 288 | def write(self, buf: str): |
| 289 | temp_linebuf = self._linebuf + buf |
| 290 | self._linebuf = "" |
| 291 | for line in temp_linebuf.splitlines(True): |
| 292 | # From the io.TextIOWrapper docs: |
| 293 | # On output, if newline is None, any '\n' characters written |
| 294 | # are translated to the system default line separator. |
| 295 | # By default sys.stdout.write() expects '\n' newlines and then |
| 296 | # translates them so this is still cross-platform. |
| 297 | if line[-1] == "\n": |
| 298 | self._logger.log( |
| 299 | self._log_level, |
| 300 | line.rstrip(), |
| 301 | stacklevel=self.get_stacklevel(), |
| 302 | ) |
| 303 | else: |
| 304 | self._linebuf += line |
| 305 | |
| 306 | def flush(self): |
| 307 | if self._linebuf != "": |