MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / emit

Method emit

tools/python-3.11.9-amd64/Lib/logging/handlers.py:973–1011  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

971 append_nul = True # some old syslog daemons expect a NUL terminator
972
973 def emit(self, record):
974 """
975 Emit a record.
976
977 The record is formatted, and then sent to the syslog server. If
978 exception information is present, it is NOT sent to the server.
979 """
980 try:
981 msg = self.format(record)
982 if self.ident:
983 msg = self.ident + msg
984 if self.append_nul:
985 msg += '\000'
986
987 # We need to convert record level to lowercase, maybe this will
988 # change in the future.
989 prio = '<%d>' % self.encodePriority(self.facility,
990 self.mapPriority(record.levelname))
991 prio = prio.encode('utf-8')
992 # Message is a string. Convert to bytes as required by RFC 5424
993 msg = msg.encode('utf-8')
994 msg = prio + msg
995
996 if not self.socket:
997 self.createSocket()
998
999 if self.unixsocket:
1000 try:
1001 self.socket.send(msg)
1002 except OSError:
1003 self.socket.close()
1004 self._connect_unixsocket(self.address)
1005 self.socket.send(msg)
1006 elif self.socktype == socket.SOCK_DGRAM:
1007 self.socket.sendto(msg, self.address)
1008 else:
1009 self.socket.sendall(msg)
1010 except Exception:
1011 self.handleError(record)
1012
1013class SMTPHandler(logging.Handler):
1014 """

Callers

nothing calls this directly

Calls 11

encodePriorityMethod · 0.95
mapPriorityMethod · 0.95
createSocketMethod · 0.95
_connect_unixsocketMethod · 0.95
formatMethod · 0.45
encodeMethod · 0.45
sendMethod · 0.45
closeMethod · 0.45
sendtoMethod · 0.45
sendallMethod · 0.45
handleErrorMethod · 0.45

Tested by

no test coverage detected