Skip to content

Commit

Permalink
Merge pull request benoitc#1291 from lyft/add-environ-variables-to-lo…
Browse files Browse the repository at this point in the history
…gger

Add environment variables to gunicorn access log format
  • Loading branch information
benoitc committed Jun 4, 2016
2 parents ef5b0f7 + 7155338 commit 26c572c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
49 changes: 25 additions & 24 deletions gunicorn/config.py
Expand Up @@ -1091,30 +1091,31 @@ class AccessLogFormat(Setting):
desc = """\
The access log format.
========== ===========
Identifier Description
========== ===========
h remote address
l ``'-'``
u user name
t date of the request
r status line (e.g. ``GET / HTTP/1.1``)
m request method
U URL path without query string
q query string
H protocol
s status
B response length
b response length or ``'-'`` (CLF format)
f referer
a user agent
T request time in seconds
D request time in microseconds
L request time in decimal seconds
p process ID
{Header}i request header
{Header}o response header
========== ===========
=========== ===========
Identifier Description
=========== ===========
h remote address
l ``'-'``
u user name
t date of the request
r status line (e.g. ``GET / HTTP/1.1``)
m request method
U URL path without query string
q query string
H protocol
s status
B response length
b response length or ``'-'`` (CLF format)
f referer
a user agent
T request time in seconds
D request time in microseconds
L request time in decimal seconds
p process ID
{Header}i request header
{Header}o response header
{Variable}e environment variable
=========== ===========
"""


Expand Down
4 changes: 4 additions & 0 deletions gunicorn/glogging.py
Expand Up @@ -303,6 +303,10 @@ def atoms(self, resp, req, environ, request_time):
# add response headers
atoms.update(dict([("{%s}o" % k.lower(), v) for k, v in resp_headers]))

# add environ variables
environ_variables = environ.items()
atoms.update(dict([("{%s}e" % k.lower(), v) for k, v in environ_variables]))

return atoms

def access(self, resp, req, environ, request_time):
Expand Down

0 comments on commit 26c572c

Please sign in to comment.