本文整理汇总了Python中process.logging.Logger.error方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.error方法的具体用法?Python Logger.error怎么用?Python Logger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类process.logging.Logger
的用法示例。
在下文中一共展示了Logger.error方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mail
# 需要导入模块: from process.logging import Logger [as 别名]
# 或者: from process.logging.Logger import error [as 别名]
def mail(errorcode, data=None, print_exception=False):
body = ""
if print_exception:
exception_info = "".join(traceback.format_exception(*sys.exc_info()))
body = body + exception_info
if data:
if not isinstance(data, basestring):
data = yaml.safe_dump([data], default_flow_style=False, allow_unicode=True)
body = body + "\n\nWhile processing:\n{data}".format(data=data)
log.error("sending failmail: " + body)
msg = MIMEText(body)
from_address = config.failmail_sender
to_address = config.failmail_recipients
if hasattr(to_address, 'split'):
to_address = to_address.split(",")
msg['Subject'] = "Fail Mail: {code} ({process})".format(code=errorcode, process=config.app_name)
msg['From'] = from_address
msg['To'] = to_address[0]
mailer = smtplib.SMTP('localhost')
mailer.sendmail(from_address, to_address, msg.as_string())
mailer.quit()