improved the logging
Dieser Commit ist enthalten in:
Ursprung
19a583b6fc
Commit
7c1a1d176d
|
@ -11,7 +11,7 @@ from gunicorn.glogging import CONFIG_DEFAULTS
|
||||||
from gunicorn.glogging import Logger as gLogger
|
from gunicorn.glogging import Logger as gLogger
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
__version__ = "0.0.5"
|
__version__ = "0.0.6"
|
||||||
|
|
||||||
|
|
||||||
CONFIG_DEFAULTS = {
|
CONFIG_DEFAULTS = {
|
||||||
|
@ -79,7 +79,11 @@ class Logger(gLogger):
|
||||||
"""See http://httpd.apache.org/docs/2.0/logs.html#combined
|
"""See http://httpd.apache.org/docs/2.0/logs.html#combined
|
||||||
for format details
|
for format details
|
||||||
"""
|
"""
|
||||||
|
level = self.access_log.info
|
||||||
|
if resp.status_code >= 400:
|
||||||
|
level = self.access_log.warning
|
||||||
|
elif resp.status_code >= 500
|
||||||
|
level = self.access_log.error
|
||||||
# wrap atoms:
|
# wrap atoms:
|
||||||
# - make sure atoms will be test case insensitively
|
# - make sure atoms will be test case insensitively
|
||||||
# - if atom doesn't exist replace it by '-'
|
# - if atom doesn't exist replace it by '-'
|
||||||
|
@ -90,6 +94,8 @@ class Logger(gLogger):
|
||||||
QUERY=environ.get("QUERY_STRING"),
|
QUERY=environ.get("QUERY_STRING"),
|
||||||
PROTOCOL=environ.get("SERVER_PROTOCOL"),
|
PROTOCOL=environ.get("SERVER_PROTOCOL"),
|
||||||
TIME="%d.%06d" % (request_time.seconds, request_time.microseconds),
|
TIME="%d.%06d" % (request_time.seconds, request_time.microseconds),
|
||||||
|
STATUS_CODE=resp.status_code,
|
||||||
|
CODE_ARGS=None,
|
||||||
)
|
)
|
||||||
if environ.get("REMOTE_ADDR", False):
|
if environ.get("REMOTE_ADDR", False):
|
||||||
extra["REMOTE"] = environ.get("REMOTE_ADDR")
|
extra["REMOTE"] = environ.get("REMOTE_ADDR")
|
||||||
|
@ -101,6 +107,6 @@ class Logger(gLogger):
|
||||||
extra["USER_AGENT"] = environ.get("HTTP_USER_AGENT")
|
extra["USER_AGENT"] = environ.get("HTTP_USER_AGENT")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.access_log.info(self.cfg.access_log_format, safe_atoms, extra=extra)
|
level(self.cfg.access_log_format, safe_atoms, extra=extra)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.error(traceback.format_exc())
|
self.error(traceback.format_exc())
|
||||||
|
|
Laden…
In neuem Issue referenzieren