-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from kingbuzzman/master
Adds the ability to change the default value of missing request_id
- Loading branch information
Showing
6 changed files
with
44 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import threading | ||
|
||
|
||
__version__ = "1.4.1" | ||
__version__ = "1.5.0" | ||
|
||
|
||
local = threading.local() | ||
|
||
|
||
REQUEST_ID_HEADER_SETTING = 'LOG_REQUEST_ID_HEADER' | ||
LOG_REQUESTS_SETTING = 'LOG_REQUESTS' | ||
NO_REQUEST_ID = "none" # Used if no request ID is available | ||
LOG_REQUESTS_NO_SETTING = 'NO_REQUEST_ID' | ||
DEFAULT_NO_REQUEST_ID = "none" # Used if no request ID is available | ||
REQUEST_ID_RESPONSE_HEADER_SETTING = 'REQUEST_ID_RESPONSE_HEADER' | ||
OUTGOING_REQUEST_ID_HEADER_SETTING = 'OUTGOING_REQUEST_ID_HEADER' | ||
GENERATE_REQUEST_ID_IF_NOT_IN_HEADER_SETTING = 'GENERATE_REQUEST_ID_IF_NOT_IN_HEADER' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import logging | ||
from log_request_id import local, NO_REQUEST_ID | ||
|
||
from django.conf import settings | ||
|
||
from log_request_id import DEFAULT_NO_REQUEST_ID, LOG_REQUESTS_NO_SETTING, local | ||
|
||
|
||
class RequestIDFilter(logging.Filter): | ||
|
||
def filter(self, record): | ||
record.request_id = getattr(local, 'request_id', NO_REQUEST_ID) | ||
default_request_id = getattr(settings, LOG_REQUESTS_NO_SETTING, DEFAULT_NO_REQUEST_ID) | ||
record.request_id = getattr(local, 'request_id', default_request_id) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters