MCPcopy Index your code
hub / github.com/python/cpython / emit

Method emit

Lib/logging/handlers.py:1081–1126  ·  view source on GitHub ↗

Emit a record. Format the record and send it to the specified addressees.

(self, record)

Source from the content-addressed store, hash-verified

1079 return self.subject
1080
1081 def emit(self, record):
1082 """
1083 Emit a record.
1084
1085 Format the record and send it to the specified addressees.
1086 """
1087 try:
1088 import smtplib
1089 from email.message import EmailMessage
1090 import email.utils
1091
1092 port = self.mailport
1093 if not port:
1094 port = smtplib.SMTP_PORT
1095 smtp = smtplib.SMTP(self.mailhost, port, timeout=self.timeout)
1096 msg = EmailMessage()
1097 msg['From'] = self.fromaddr
1098 msg['To'] = ','.join(self.toaddrs)
1099 msg['Subject'] = self.getSubject(record)
1100 msg['Date'] = email.utils.localtime()
1101 msg.set_content(self.format(record))
1102 if self.username:
1103 if self.secure is not None:
1104 import ssl
1105
1106 try:
1107 keyfile = self.secure[0]
1108 except IndexError:
1109 keyfile = None
1110
1111 try:
1112 certfile = self.secure[1]
1113 except IndexError:
1114 certfile = None
1115
1116 context = ssl._create_stdlib_context(
1117 certfile=certfile, keyfile=keyfile
1118 )
1119 smtp.ehlo()
1120 smtp.starttls(context=context)
1121 smtp.ehlo()
1122 smtp.login(self.username, self.password)
1123 smtp.send_message(msg)
1124 smtp.quit()
1125 except Exception:
1126 self.handleError(record)
1127
1128class NTEventLogHandler(logging.Handler):
1129 """

Callers 2

emitMethod · 0.45
emitMethod · 0.45

Calls 11

getSubjectMethod · 0.95
set_contentMethod · 0.95
ehloMethod · 0.95
starttlsMethod · 0.95
loginMethod · 0.95
send_messageMethod · 0.95
quitMethod · 0.95
EmailMessageClass · 0.90
joinMethod · 0.45
formatMethod · 0.45
handleErrorMethod · 0.45

Tested by

no test coverage detected