API: Log more information about a request
Required for log reviewing. The ACL will now log information about the request and who made it Change-Id: Icf7690c3e4e0352b93884eb79724d2517062b018
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import importlib
|
import importlib
|
||||||
|
import logging
|
||||||
|
from pecan import request
|
||||||
|
|
||||||
|
|
||||||
def install(app, args):
|
def install(app, args):
|
||||||
@@ -28,4 +30,16 @@ def install(app, args):
|
|||||||
|
|
||||||
def get_limited_to_project(headers):
|
def get_limited_to_project(headers):
|
||||||
"""Return the tenant the request should be limited to."""
|
"""Return the tenant the request should be limited to."""
|
||||||
return headers.get('X-Tenant-Id')
|
tenant_id = headers.get('X-Tenant-Id')
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
logger.info(
|
||||||
|
'Loadbalancers {0} request {1} ({2}) from {3} tenant {4}'.format(
|
||||||
|
request.environ.get('REQUEST_METHOD'),
|
||||||
|
request.environ.get('PATH_INFO'),
|
||||||
|
request.environ.get('QUERY_STRING'),
|
||||||
|
request.environ.get('REMOTE_ADDR'),
|
||||||
|
tenant_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return tenant_id
|
||||||
|
|||||||
Reference in New Issue
Block a user