MCPcopy Index your code
hub / github.com/RustPython/RustPython / emit

Method emit

Lib/logging/handlers.py:1074–1119  ·  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

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

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