Skip to content

Commit

Permalink
Added logging tender_status, tender_id and tenderID
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Jan 26, 2015
1 parent f61f9e9 commit 92313ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/openprocurement/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ def error_handler(errors):
if errors.request.matchdict:
for x, j in errors.request.matchdict.items():
i._extra[x.upper()] = j
if 'tender' in errors.request.validated:
i._extra['TENDERID'] = errors.request.validated['tender'].tenderID
i._extra['TENDER_STATUS'] = errors.request.validated['tender'].status
LOGGER.info('Error on processing request "{}"'.format(dumps(errors, indent=4)), extra={'MESSAGE_ID': 'error_handler'})
for i in LOGGER.handlers:
LOGGER.removeHandler(i)
Expand Down Expand Up @@ -256,8 +259,18 @@ def update_journal_handler_role(event):
if request.matchdict:
for x, j in request.matchdict.items():
i._extra[x.upper()] = j
if 'tender' in request.validated:
i._extra['TENDERID'] = request.validated['tender'].tenderID
i._extra['TENDER_STATUS'] = request.validated['tender'].status


def cleanup_journal_handler(event):
for i in LOGGER.handlers:
LOGGER.removeHandler(i)


def update_journal_handler_params(params):
for i in LOGGER.handlers:
if isinstance(i, JournalHandler):
for x, j in params.items():
i._extra[x.upper()] = j
4 changes: 3 additions & 1 deletion src/openprocurement/api/views/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
apply_patch,
add_next_award,
error_handler,
update_journal_handler_params,
)
from openprocurement.api.validation import (
validate_patch_tender_data,
Expand Down Expand Up @@ -268,7 +269,8 @@ def collection_post(self):
self.request.validated['tender'] = tender
self.request.validated['tender_src'] = {}
if save_tender(self.request):
LOGGER.info('Created tender {}'.format(tender_id), extra={'MESSAGE_ID': 'tender_create'})
update_journal_handler_params({'tender_id': tender_id, 'tenderID': tender.tenderID})
LOGGER.info('Created tender {} ({})'.format(tender_id, tender.tenderID), extra={'MESSAGE_ID': 'tender_create'})
self.request.response.status = 201
self.request.response.headers[
'Location'] = self.request.route_url('Tender', tender_id=tender_id)
Expand Down

0 comments on commit 92313ae

Please sign in to comment.