-
Notifications
You must be signed in to change notification settings - Fork 11
Feature django logging #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature django logging #30
Conversation
* Export logging middleware to be added in django app for logging capabilities * Write tests for logging in sample django app
README.rst
Outdated
Django | ||
^^^^^^ | ||
|
||
For django logging you have to edit a couple of files: |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
Add support for logging in cf format for django framework.