From 0756ba723c909d3448dce7e1fa7fa1069975a91d Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 25 Jun 2013 13:38:27 +0100 Subject: [PATCH] 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 --- libra/api/acl.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libra/api/acl.py b/libra/api/acl.py index 82f92625..901f327c 100644 --- a/libra/api/acl.py +++ b/libra/api/acl.py @@ -14,6 +14,8 @@ import ConfigParser import importlib +import logging +from pecan import request def install(app, args): @@ -28,4 +30,16 @@ def install(app, args): def get_limited_to_project(headers): """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