errormail: adjust flask import
This commit is contained in:
parent
89fe3404aa
commit
274ac0574c
|
@ -5,7 +5,6 @@ from logging import Formatter
|
||||||
from logging.handlers import SMTPHandler
|
from logging.handlers import SMTPHandler
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
from flask import g, request
|
|
||||||
|
|
||||||
PROJECT = "geocode"
|
PROJECT = "geocode"
|
||||||
|
|
||||||
|
@ -21,10 +20,10 @@ class MySMTPHandler(SMTPHandler):
|
||||||
else f"{PROJECT} error: {record.pathname}:{record.lineno:d}"
|
else f"{PROJECT} error: {record.pathname}:{record.lineno:d}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if qid := getattr(g, "qid", None):
|
if qid := getattr(flask.g, "qid", None):
|
||||||
subject += f" {qid}"
|
subject += f" {qid}"
|
||||||
|
|
||||||
if label := getattr(g, "label", None):
|
if label := getattr(flask.g, "label", None):
|
||||||
subject += f": {label}"
|
subject += f": {label}"
|
||||||
|
|
||||||
return subject
|
return subject
|
||||||
|
@ -35,7 +34,7 @@ class RequestFormatter(Formatter):
|
||||||
|
|
||||||
def format(self, record: logging.LogRecord) -> str:
|
def format(self, record: logging.LogRecord) -> str:
|
||||||
"""Record includes request."""
|
"""Record includes request."""
|
||||||
record.request = request
|
record.request = flask.request
|
||||||
return super().format(record)
|
return super().format(record)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue