瀏覽代碼

Adaption to new logging

master
Dirk Alders 3 年之前
父節點
當前提交
176794a3fc
共有 7 個文件被更改,包括 22 次插入45 次删除
  1. 2
    0
      .gitignore
  2. 1
    2
      README.md
  3. 16
    23
      main/settings.py
  4. 1
    1
      mycreole
  5. 1
    1
      patt
  6. 0
    17
      readme.txt
  7. 1
    1
      users

+ 2
- 0
.gitignore 查看文件

@@ -1,6 +1,8 @@
1 1
 config.py
2 2
 data/
3
+
3 4
 venv
5
+.settings
4 6
 
5 7
 # ---> Python
6 8
 # Byte-compiled / optimized / DLL files

+ 1
- 2
README.md 查看文件

@@ -87,13 +87,12 @@ and set the Variable ALLOWED_HOSTS. Execute
87 87
     python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e sessions -e auth.Permission -e sessions patt --indent 2 > dump_patt.json
88 88
     tar -cvzf dump_media.tgz data/media
89 89
 
90
-**Further Files need to be backuped! **
91 90
 
92 91
 ### Restore Backup
93 92
 
94 93
     source venv/bin/activate
95 94
 
96
-If you are starting with any database, you need to create one
95
+If you are starting without a database, you need to create one
97 96
 
98 97
     python manage.py migrate
99 98
 

+ 16
- 23
main/settings.py 查看文件

@@ -11,6 +11,7 @@ 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
@@ -194,8 +195,14 @@ PERSISTENT_SESSION_VARIABLES = []
194 195
 
195 196
 # Logging Configuration
196 197
 #
197
-debug_handler = 'console'
198
-default_handler = [debug_handler] if DEBUG else ['console']
198
+class DjangoSocketHandler(_SocketHandler):
199
+    def emit(self, record):
200
+        if hasattr(record, 'request'):
201
+            record.request = None
202
+        return super().emit(record)
203
+
204
+
205
+default_handler = ['socket'] if DEBUG else ['console']
199 206
 #
200 207
 LOGGING = {
201 208
     'version': 1,
@@ -218,36 +225,22 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
218 225
             'class': 'logging.StreamHandler',
219 226
             'formatter': 'short',
220 227
         },
221
-        'console_long': {
228
+        'socket': {
222 229
             'level': 'DEBUG',
223
-            'class': 'logging.StreamHandler',
224
-            'formatter': 'long',
230
+            'class': 'main.settings.DjangoSocketHandler',
231
+            'host': '127.0.0.1',
232
+            'port': 19996,
225 233
         },
226 234
     },
227 235
     'loggers': {
228
-        'AUTH': {
229
-            'handlers': default_handler,
230
-            'level': 'INFO',
231
-            'propagate': False,
232
-        },
233
-        'ACC': {
234
-            'handlers': default_handler,
235
-            'level': 'INFO',
236
-            'propagate': False,
237
-        },
238
-        'APP': {
239
-            'handlers': default_handler,
240
-            'level': 'INFO',
241
-            'propagate': False,
242
-        },
243
-        'WHOOSH': {
236
+        'django': {
244 237
             'handlers': default_handler,
245 238
             'level': 'INFO',
246 239
             'propagate': False,
247 240
         },
248
-        'FSTOOLS': {
241
+        config.APP_NAME: {
249 242
             'handlers': default_handler,
250
-            'level': 'INFO',
243
+            'level': 'DEBUG' if DEBUG else 'INFO',
251 244
             'propagate': False,
252 245
         },
253 246
     },

+ 1
- 1
mycreole

@@ -1 +1 @@
1
-Subproject commit dd0edc2d56c2c234be32fa76e3bd5b6b4f38a69f
1
+Subproject commit 5f30383c83b0ea94341b999c489a34f2e7d57f80

+ 1
- 1
patt

@@ -1 +1 @@
1
-Subproject commit 63e9af4d65a486309e55bb0925866fb1eaec99cb
1
+Subproject commit be03b653ebce2dadb5bfb314e597966751fb9cf7

+ 0
- 17
readme.txt 查看文件

@@ -1,17 +0,0 @@
1
-1. Setupt venev
2
-  * virtualenv -p /usr/bin/python3 patt-venv
3
-  * ln -s patt-venv/bin/activate
4
-  * source activate
5
-  * Sometimes upgrades are needed: pip list --outdated | cut -d ' ' -f 1 | xargs pip install $1 --upgrade
6
-  * pip install -r requirements.txt
7
-2. Set SECRET:KEY in config.py
8
-3. python manage.py migrate
9
-4. python manage.py createsuperuser
10
-5. python manage.py collectstatic
11
-6. chgrp www-data . && chmod 770 .
12
-7. chgrp www-data db.sqlite3 && chmod 664 db.sqlite3
13
-8. chgrp www-data -R data
14
-8.1. find data -type d -exec chmod 775 "{}" \;
15
-8.2. find data -type f -exec chmod 664 "{}" \;
16
-
17
-x. Run server by command "python manage.py runserver 0.0.0.0:8000" or add App to apache

+ 1
- 1
users

@@ -1 +1 @@
1
-Subproject commit 8cf64464ba094df60fe81442dd0d728075368344
1
+Subproject commit 0827a5311fdbbef689365c6db5762881e048ba9c

Loading…
取消
儲存