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

Method emit

tools/python-3.11.9-amd64/Lib/logging/handlers.py:1061–1091  ·  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

1059 return self.subject
1060
1061 def emit(self, record):
1062 """
1063 Emit a record.
1064
1065 Format the record and send it to the specified addressees.
1066 """
1067 try:
1068 import smtplib
1069 from email.message import EmailMessage
1070 import email.utils
1071
1072 port = self.mailport
1073 if not port:
1074 port = smtplib.SMTP_PORT
1075 smtp = smtplib.SMTP(self.mailhost, port, timeout=self.timeout)
1076 msg = EmailMessage()
1077 msg['From'] = self.fromaddr
1078 msg['To'] = ','.join(self.toaddrs)
1079 msg['Subject'] = self.getSubject(record)
1080 msg['Date'] = email.utils.localtime()
1081 msg.set_content(self.format(record))
1082 if self.username:
1083 if self.secure is not None:
1084 smtp.ehlo()
1085 smtp.starttls(*self.secure)
1086 smtp.ehlo()
1087 smtp.login(self.username, self.password)
1088 smtp.send_message(msg)
1089 smtp.quit()
1090 except Exception:
1091 self.handleError(record)
1092
1093class NTEventLogHandler(logging.Handler):
1094 """

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