Emit a record. The record is formatted, and then sent to the syslog server. If exception information is present, it is NOT sent to the server.
(self, record)
| 990 | append_nul = True # some old syslog daemons expect a NUL terminator |
| 991 | |
| 992 | def emit(self, record): |
| 993 | """ |
| 994 | Emit a record. |
| 995 | |
| 996 | The record is formatted, and then sent to the syslog server. If |
| 997 | exception information is present, it is NOT sent to the server. |
| 998 | """ |
| 999 | try: |
| 1000 | msg = self.format(record) |
| 1001 | if self.ident: |
| 1002 | msg = self.ident + msg |
| 1003 | if self.append_nul: |
| 1004 | msg += '\000' |
| 1005 | |
| 1006 | # We need to convert record level to lowercase, maybe this will |
| 1007 | # change in the future. |
| 1008 | prio = '<%d>' % self.encodePriority(self.facility, |
| 1009 | self.mapPriority(record.levelname)) |
| 1010 | prio = prio.encode('utf-8') |
| 1011 | # Message is a string. Convert to bytes as required by RFC 5424 |
| 1012 | msg = msg.encode('utf-8') |
| 1013 | msg = prio + msg |
| 1014 | |
| 1015 | if not self.socket: |
| 1016 | self.createSocket() |
| 1017 | |
| 1018 | if self.unixsocket: |
| 1019 | try: |
| 1020 | self.socket.send(msg) |
| 1021 | except OSError: |
| 1022 | self.socket.close() |
| 1023 | self._connect_unixsocket(self.address) |
| 1024 | self.socket.send(msg) |
| 1025 | elif self.socktype == socket.SOCK_DGRAM: |
| 1026 | self.socket.sendto(msg, self.address) |
| 1027 | else: |
| 1028 | self.socket.sendall(msg) |
| 1029 | except Exception: |
| 1030 | self.handleError(record) |
| 1031 | |
| 1032 | class SMTPHandler(logging.Handler): |
| 1033 | """ |
nothing calls this directly
no test coverage detected