|
@@ -11,11 +11,17 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
|
11
|
11
|
"""
|
12
|
12
|
|
13
|
13
|
import config
|
|
14
|
+from logging.handlers import SocketHandler as _SocketHandler
|
14
|
15
|
import os
|
15
|
16
|
import stat
|
16
|
17
|
import sys
|
17
|
18
|
import random
|
18
|
19
|
|
|
20
|
+try:
|
|
21
|
+ from config import APP_NAME as ROOT_LOGGER_NAME
|
|
22
|
+except ImportError:
|
|
23
|
+ ROOT_LOGGER_NAME = 'root'
|
|
24
|
+
|
19
|
25
|
|
20
|
26
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
21
|
27
|
#
|
|
@@ -64,7 +70,7 @@ for property_name in USER_CONFIG_DEFAULTS:
|
64
|
70
|
if SECRET_KEY is None:
|
65
|
71
|
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
66
|
72
|
s_key = ''.join([random.choice(chars) for n in range(50)])
|
67
|
|
- secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: %s)." % repr(s_key)
|
|
73
|
+ secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
|
68
|
74
|
raise KeyError(secret_key_warning)
|
69
|
75
|
|
70
|
76
|
|
|
@@ -194,7 +200,14 @@ PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_
|
194
|
200
|
|
195
|
201
|
# Logging Configuration
|
196
|
202
|
#
|
197
|
|
-default_handler = ['console_long'] if DEBUG else ['console']
|
|
203
|
+class DjangoSocketHandler(_SocketHandler):
|
|
204
|
+ def emit(self, record):
|
|
205
|
+ if hasattr(record, 'request'):
|
|
206
|
+ record.request = None
|
|
207
|
+ return super().emit(record)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+default_handler = ['socket'] if DEBUG else ['console']
|
198
|
211
|
#
|
199
|
212
|
LOGGING = {
|
200
|
213
|
'version': 1,
|
|
@@ -217,46 +230,22 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
|
217
|
230
|
'class': 'logging.StreamHandler',
|
218
|
231
|
'formatter': 'short',
|
219
|
232
|
},
|
220
|
|
- 'console_long': {
|
|
233
|
+ 'socket': {
|
221
|
234
|
'level': 'DEBUG',
|
222
|
|
- 'class': 'logging.StreamHandler',
|
223
|
|
- 'formatter': 'long',
|
|
235
|
+ 'class': 'main.settings.DjangoSocketHandler',
|
|
236
|
+ 'host': '127.0.0.1',
|
|
237
|
+ 'port': 19996,
|
224
|
238
|
},
|
225
|
239
|
},
|
226
|
240
|
'loggers': {
|
227
|
|
- 'AUTH': {
|
|
241
|
+ 'django': {
|
228
|
242
|
'handlers': default_handler,
|
229
|
243
|
'level': 'INFO',
|
230
|
244
|
'propagate': False,
|
231
|
245
|
},
|
232
|
|
- 'APP': {
|
|
246
|
+ ROOT_LOGGER_NAME: {
|
233
|
247
|
'handlers': default_handler,
|
234
|
|
- 'level': 'INFO',
|
235
|
|
- 'propagate': False,
|
236
|
|
- },
|
237
|
|
- 'CACHING': {
|
238
|
|
- 'handlers': default_handler,
|
239
|
|
- 'level': 'INFO',
|
240
|
|
- 'propagate': False,
|
241
|
|
- },
|
242
|
|
- 'WHOOSH': {
|
243
|
|
- 'handlers': default_handler,
|
244
|
|
- 'level': 'INFO',
|
245
|
|
- 'propagate': False,
|
246
|
|
- },
|
247
|
|
- 'FSTOOLS': {
|
248
|
|
- 'handlers': default_handler,
|
249
|
|
- 'level': 'INFO',
|
250
|
|
- 'propagate': False,
|
251
|
|
- },
|
252
|
|
- 'GEO': {
|
253
|
|
- 'handlers': default_handler,
|
254
|
|
- 'level': 'INFO',
|
255
|
|
- 'propagate': False,
|
256
|
|
- },
|
257
|
|
- 'MEDIA': {
|
258
|
|
- 'handlers': default_handler,
|
259
|
|
- 'level': 'INFO',
|
|
248
|
+ 'level': 'DEBUG' if DEBUG else 'INFO',
|
260
|
249
|
'propagate': False,
|
261
|
250
|
},
|
262
|
251
|
},
|