Skip to content

Commit

Permalink
Added TENDERS_API_VERSION and REQUEST_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Feb 2, 2015
1 parent cb09723 commit 20ec5ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/openprocurement/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import gevent.monkey
gevent.monkey.patch_all()
import os
import pkg_resources
from pkg_resources import get_distribution
from pyramid.config import Configurator
from openprocurement.api.auth import AuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy as AuthorizationPolicy
Expand All @@ -23,7 +23,8 @@
JournalHandler = False

#VERSION = int(pkg_resources.get_distribution(__package__).parsed_version[0])
VERSION = pkg_resources.get_distribution(__package__).version
PKG = get_distribution(__package__)
VERSION = '{}.{}'.format(int(PKG.parsed_version[0]), int(PKG.parsed_version[1]))
ROUTE_PREFIX = '/api/{}'.format(VERSION)


Expand Down
7 changes: 6 additions & 1 deletion src/openprocurement/api/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from pkg_resources import get_distribution
from logging import getLogger
from base64 import b64encode
from jsonpatch import make_patch, apply_patch as _apply_patch
Expand All @@ -18,7 +19,9 @@
JournalHandler = False


LOGGER = getLogger('openprocurement.api')
PKG = get_distribution(__package__)
LOGGER = getLogger(PKG.project_name)
VERSION = '{}.{}'.format(int(PKG.parsed_version[0]), int(PKG.parsed_version[1]))


def generate_id():
Expand Down Expand Up @@ -251,6 +254,7 @@ def forbidden(request):
def set_journal_handler(event):
request = event.request
params = {
'TENDERS_API_VERSION': VERSION,
'TAGS': 'python,api',
'USER_ID': str(request.authenticated_userid or ''),
#'ROLE': str(request.authenticated_role),
Expand All @@ -266,6 +270,7 @@ def set_journal_handler(event):
'QUESTION_ID': '',
'TENDER_ID': '',
'TIMESTAMP': get_now().isoformat(),
'REQUEST_ID': request.environ.get('REQUEST_ID', '')
}
for i in LOGGER.handlers:
LOGGER.removeHandler(i)
Expand Down

0 comments on commit 20ec5ac

Please sign in to comment.