You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-6Lines changed: 49 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ LOGGING = {
44
44
45
45
## Details
46
46
47
-
Most of times you don't have to care about these details. But in case you need to dig deep:
47
+
Most of the times you don't have to care about these details. But in case you need to dig deep:
48
48
49
49
* All logs are configured using logger name "django.request".
50
50
* If HTTP status code is between 400 - 599, URIs are logged at ERROR level, otherwise they are logged at INFO level.
@@ -53,7 +53,40 @@ Most of times you don't have to care about these details. But in case you need t
53
53
See `REQUEST_LOGGING_HTTP_4XX_LOG_LEVEL` setting to override this.
54
54
55
55
56
-
A `no_logging` decorator is included for views with sensitive data.
56
+
A `no_logging` decorator is included for views with sensitive data. This decorator allows control over logging behaviour of single views via the following parameters:
57
+
```
58
+
* value
59
+
* False: the view does NOT log any activity at all (overrules settings of log_headers, log_body, log_response and automatically sets them to False).
60
+
* True: the view logs incoming requests (potentially log headers, body and response, depending on their specific settings)
61
+
* None: NO_LOGGING_DEFAULT_VALUE is used (can be defined in settings file as DJANGO_REQUEST_LOGGING_NO_LOGGING_DEFAULT_VALUE)
62
+
* msg
63
+
* Reason for deactivation of logging gets logged instead of request itself (only if silent=True and value=False)
64
+
* NO_LOGGING_MSG is used by default
65
+
* log_headers
66
+
* False: request headers will not get logged
67
+
* True: request headers will get logged (if value is True)
68
+
* None: LOG_HEADERS_DEFAULT_VALUE is used (can be defined in settings file as DJANGO_REQUEST_LOGGING_LOG_HEADERS_DEFAULT_VALUE)
69
+
* no_header_logging_msg
70
+
* Reason for deactivation of header logging gets logged instead of headers (only if silent=True and log_headers=False)
71
+
* NO_HEADER_LOGGING_MSG is used by default
72
+
* log_body
73
+
* False: request body will not get logged
74
+
* True: request headers will get logged (if value is True)
75
+
* None: LOG_BODY_DEFAULT_VALUE is used (can be defined in settings file as DJANGO_REQUEST_LOGGING_LOG_BODY_DEFAULT_VALUE)
76
+
* no_body_logging_msg
77
+
* Reason for deactivation of body logging gets logged instead of body (only if silent=True and log_body=False)
78
+
* NO_BODY_LOGGING_MSG is used by default
79
+
* log_response
80
+
* False: response will not get logged
81
+
* True: response will get logged (if value is True)
82
+
* None: LOG_RESPONSE_DEFAULT_VALUE is used (can be defined in settings file as DJANGO_REQUEST_LOGGING_LOG_RESPONSE_DEFAULT_VALUE)
83
+
* no_response_logging_msg
84
+
* Reason for deactivation of body logging gets logged instead of body (only if silent=True and log_body=False)
85
+
* NO_RESPONSE_LOGGING_MSG is used by default
86
+
* silent
87
+
* True: deactivate logging of alternative messages case parts of the logging are deactivated (request/header/body/response)
88
+
* False: alternative messages for deactivated parts of logging (request/header/body/response) are logged instead
89
+
```
57
90
58
91
By default, value of Http headers `HTTP_AUTHORIZATION` and `HTTP_PROXY_AUTHORIZATION` are replaced wih `*****`. You can use `REQUEST_LOGGING_SENSITIVE_HEADERS` setting to override this default behaviour with your list of sensitive headers.
59
92
@@ -73,13 +106,23 @@ By default, HTTP status codes between 400 - 499 are logged at ERROR level. You
73
106
If you set `REQUEST_LOGGING_HTTP_4XX_LOG_LEVEL=logging.INFO` they will be logged the same as normal requests.
74
107
### REQUEST_LOGGING_SENSITIVE_HEADERS
75
108
The value of the headers defined in this settings will be replaced with `'*****'` to hide the sensitive information while logging. By default it is set as `REQUEST_LOGGING_SENSITIVE_HEADERS = ["HTTP_AUTHORIZATION", "HTTP_PROXY_AUTHORIZATION"]`
109
+
### DJANGO_REQUEST_LOGGING_LOGGER_NAME
110
+
Name of the logger that is used to log django.request occurrances with the new LoggingMiddleware. Defaults to "django.request".
Global default to activate/deactivate logging of all views. Can be overruled for each individual view by using the @no_logging decator's "value" parameter.
Global default to activate/deactivate logging of request headers for all views. Can be overruled for each individual view by using the @no_logging decator's "log_headers" parameter.
Global default to activate/deactivate logging of request bodys for all views. Can be overruled for each individual view by using the @no_logging decator's "log_body" parameter.
Global default to activate/deactivate logging of responses for all views. Can be overruled for each individual view by using the @no_logging decator's "log_response" parameter.
76
119
77
120
78
121
## Deploying, Etc.
79
122
80
123
### Maintenance
81
124
82
-
Use `pyenv` to maintain a set of virtualenvs for 2.7 and a couple versions of Python 3.
125
+
Use `pyenv` to maintain a set of virtualenvs for 2.7 and a couple versions of Python 3.
83
126
Make sure the `requirements-dev.txt` installs for all of them, at least until we give up on 2.7.
84
127
At that point, update this README to let users know the last version they can use with 2.7.
85
128
@@ -93,17 +136,17 @@ At that point, update this README to let users know the last version they can us
93
136
index-servers=
94
137
testpypi
95
138
pypi
96
-
139
+
97
140
[testpypi]
98
141
username = rhumbix
99
142
password = password for dev@rhumbix.com at Pypi
100
-
143
+
101
144
[pypi]
102
145
username = rhumbix
103
146
password = password for dev@rhumbix.com at Pypi
104
147
```
105
148
106
-
### Publishing
149
+
### Publishing
107
150
108
151
- Bump the version value in `request_logging/__init__.py`
0 commit comments