Emit a record. If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print
(self, record)
| 79 | logging.StreamHandler.__init__(self, stream) |
| 80 | |
| 81 | def emit(self, record): |
| 82 | """ |
| 83 | Emit a record. |
| 84 | |
| 85 | If a formatter is specified, it is used to format the record. |
| 86 | The record is then written to the stream with a trailing newline. If |
| 87 | exception information is present, it is formatted using |
| 88 | traceback.print_exception and appended to the stream. If the stream |
| 89 | has an 'encoding' attribute, it is used to determine how to do the |
| 90 | output to the stream. |
| 91 | """ |
| 92 | try: |
| 93 | msg = self.format(record) |
| 94 | stream = self.stream |
| 95 | # issue 35046: merged two stream.writes into one. |
| 96 | stream.write(record.levelno, msg + self.terminator) |
| 97 | self.flush() |
| 98 | except RecursionError: # See issue 36272 |
| 99 | raise |
| 100 | except Exception: |
| 101 | self.handleError(record) |
| 102 | |
| 103 | formatter = logging.Formatter("%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s", datefmt=logging.Formatter.default_time_format) |
| 104 | ch = Stream2Handler(stream2) |
no test coverage detected