Skip to content
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

[Do Not Merge] [Example] Add per-request logging context #481

Closed
wants to merge 1 commit into from

Conversation

coltonlw
Copy link
Contributor

@coltonlw coltonlw commented Sep 8, 2016

This adds a custom request object which has additional attributes "id" and "logger". logger is a LoggerAdapter which adds the request id to each message string. In the future this can be expanded to include additional per-request context information with each logging call, including extra keys when we log in JSON. Also added a thread local request context which can be accessed globally via set_current_request and get_current_request

Example output:

2016-09-08 11:09:46 scitran.api base.py  105:INFO Initialized request request_id=0935954b-1473350986

Fixes: #199, #451

@coltonlw coltonlw force-pushed the add-request-logging branch from 9b2ea12 to 941aa6e Compare September 8, 2016 16:40
@coltonlw
Copy link
Contributor Author

coltonlw commented Sep 8, 2016

FYI pushed a one-line change to remove unused request_id attribute

@coltonlw
Copy link
Contributor Author

coltonlw commented Sep 8, 2016

Talking to Megan, I'm going to make a new feature branch which does not have global request context / set_current_request + get_current_request functionality. Most of the logger calls that do not already have access to the request are of level debug and so not useful in production anyway and not worth the complexity of the global request context. I'll leave this open incase anyone still wants to review the implementation for curiosity sake

@coltonlw coltonlw changed the title Add per-request logging context [Do Not Merge] [Example] Add per-request logging context Sep 8, 2016
@coltonlw
Copy link
Contributor Author

coltonlw commented Sep 8, 2016

Closing because the new PR will be opened from a different branch

@coltonlw coltonlw closed this Sep 8, 2016
@coltonlw coltonlw deleted the add-request-logging branch September 12, 2016 16:40
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.

4 participants