Skip to content

Conversation

georgi-bozhinov
Copy link
Contributor

Add support for logging in cf format for django framework.

README.rst Outdated
Django
^^^^^^

For django logging you have to edit a couple of files:
Copy link
Contributor

@alexpenev-s alexpenev-s Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe without this line (like the sections above)

README.rst Outdated
url('example/', include('example_app.urls'))
]
**Note**: The library works with Django 2.x as well, the example is in an earlier version for python 2 compatibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an example to how to make it work in Django 2.x? Could we link it?

conftest.py Outdated
if sys.version_info < (3, 5):
collect_ignore = ['tests/test_sanic_logging.py']

os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.django_logging.test_app.settings'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to do this in the test only, because we don't need this env variable for the other tests.

import uuid

CORRELATION_ID_HEADERS = ['X-Correlation-ID',
CORRELATION_ID_HEADERS = ['x-Correlation-ID',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed needed? I believe X-Correlation-ID is the standard name.

self._get_response = get_response

def __call__(self, request):
response = self.process_request(request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response is always None right? Why is this check done here?

request.context[key] = value

def get(self, key, request):
return request.context.get(key) if request else None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the context be inited here as well?

@georgi-bozhinov georgi-bozhinov merged commit e4d413c into SAP:master Jul 27, 2018
@georgi-bozhinov georgi-bozhinov deleted the feature-django-logging branch July 27, 2018 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants