|
@@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/5.1/ref/settings/
|
13
|
13
|
from pathlib import Path
|
14
|
14
|
|
15
|
15
|
import config
|
|
16
|
+from logging.handlers import SocketHandler as _SocketHandler
|
16
|
17
|
import os
|
17
|
18
|
import random
|
18
|
19
|
import stat
|
|
@@ -182,12 +183,22 @@ if SECRET_KEY is None:
|
182
|
183
|
# Logging Configuration
|
183
|
184
|
#
|
184
|
185
|
ROOT_LOGGER_NAME = 'apps'
|
|
186
|
+default_handler = ['socket'] if DEBUG else ['console']
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+class DjangoSocketHandler(_SocketHandler):
|
|
190
|
+ def emit(self, record):
|
|
191
|
+ if hasattr(record, 'request'):
|
|
192
|
+ record.request = None
|
|
193
|
+ return super().emit(record)
|
|
194
|
+
|
|
195
|
+
|
185
|
196
|
LOGGING = {
|
186
|
197
|
'version': 1,
|
187
|
198
|
'disable_existing_loggers': False,
|
188
|
199
|
'formatters': {
|
189
|
200
|
'short': {
|
190
|
|
- 'format': "%(name)25s - %(levelname)10s - %(message)s",
|
|
201
|
+ 'format': "%(asctime)s \"%(name)s - %(levelname)s - %(message)s\"",
|
191
|
202
|
'datefmt': '[%d/%b/%Y %H:%M:%S]',
|
192
|
203
|
},
|
193
|
204
|
'long': {
|
|
@@ -203,15 +214,21 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
|
203
|
214
|
'class': 'logging.StreamHandler',
|
204
|
215
|
'formatter': 'short',
|
205
|
216
|
},
|
|
217
|
+ 'socket': {
|
|
218
|
+ 'level': 'DEBUG',
|
|
219
|
+ 'class': 'piki.settings.DjangoSocketHandler',
|
|
220
|
+ 'host': '127.0.0.1',
|
|
221
|
+ 'port': 19996,
|
|
222
|
+ },
|
206
|
223
|
},
|
207
|
224
|
'loggers': {
|
208
|
225
|
'django': {
|
209
|
|
- 'handlers': ['console'],
|
|
226
|
+ 'handlers': default_handler,
|
210
|
227
|
'level': 'INFO',
|
211
|
228
|
'propagate': False,
|
212
|
229
|
},
|
213
|
230
|
ROOT_LOGGER_NAME: {
|
214
|
|
- 'handlers': ['console'],
|
|
231
|
+ 'handlers': default_handler,
|
215
|
232
|
'level': 'DEBUG' if DEBUG else 'INFO',
|
216
|
233
|
'propagate': False,
|
217
|
234
|
},
|