本文整理匯總了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()