Prepare a record for queuing. The object returned by this method is enqueued. The base implementation formats the record to merge the message and arguments, and removes unpickleable items from the record in-place. Specifically, it overwrites the record's `ms
(self, record)
| 1487 | self.queue.put_nowait(record) |
| 1488 | |
| 1489 | def prepare(self, record): |
| 1490 | """ |
| 1491 | Prepare a record for queuing. The object returned by this method is |
| 1492 | enqueued. |
| 1493 | |
| 1494 | The base implementation formats the record to merge the message and |
| 1495 | arguments, and removes unpickleable items from the record in-place. |
| 1496 | Specifically, it overwrites the record's `msg` and |
| 1497 | `message` attributes with the merged message (obtained by |
| 1498 | calling the handler's `format` method), and sets the `args`, |
| 1499 | `exc_info` and `exc_text` attributes to None. |
| 1500 | |
| 1501 | You might want to override this method if you want to convert |
| 1502 | the record to a dict or JSON string, or send a modified copy |
| 1503 | of the record while leaving the original intact. |
| 1504 | """ |
| 1505 | # The format operation gets traceback text into record.exc_text |
| 1506 | # (if there's exception data), and also returns the formatted |
| 1507 | # message. We can then use this to replace the original |
| 1508 | # msg + args, as these might be unpickleable. We also zap the |
| 1509 | # exc_info, exc_text and stack_info attributes, as they are no longer |
| 1510 | # needed and, if not None, will typically not be pickleable. |
| 1511 | msg = self.format(record) |
| 1512 | # bpo-35726: make copy of record to avoid affecting other handlers in the chain. |
| 1513 | record = copy.copy(record) |
| 1514 | record.message = msg |
| 1515 | record.msg = msg |
| 1516 | record.args = None |
| 1517 | record.exc_info = None |
| 1518 | record.exc_text = None |
| 1519 | record.stack_info = None |
| 1520 | return record |
| 1521 | |
| 1522 | def emit(self, record): |
| 1523 | """ |