Kaynağa Gözat

Adaption to new logging

master
Dirk Alders 3 yıl önce
ebeveyn
işleme
3a94e857aa
11 değiştirilmiş dosya ile 55 ekleme ve 58 silme
  1. 23
    0
      .gitignore
  2. 3
    0
      config_example/config.py
  3. 1
    1
      fstools
  4. 1
    1
      geo
  5. 22
    33
      main/settings.py
  6. 1
    1
      media
  7. 1
    1
      mycreole
  8. 1
    1
      pygal
  9. 0
    18
      readme.txt
  10. 1
    1
      stringtools
  11. 1
    1
      users

+ 23
- 0
.gitignore Dosyayı Görüntüle

@@ -1,6 +1,7 @@
1 1
 config.py
2 2
 data/
3 3
 
4
+venv
4 5
 .settings
5 6
 
6 7
 # ---> Python
@@ -119,3 +120,25 @@ dmypy.json
119 120
 # Pyre type checker
120 121
 .pyre/
121 122
 
123
+# ---> Linux
124
+*~
125
+
126
+# temporary files which can be created if a process still has a handle open of a deleted file
127
+.fuse_hidden*
128
+
129
+# KDE directory preferences
130
+.directory
131
+
132
+# Linux trash folder which might appear on any partition or disk
133
+.Trash-*
134
+
135
+# .nfs files are created when an open file is removed but is still being accessed
136
+.nfs*
137
+
138
+# ---> Backup
139
+*.bak
140
+*.gho
141
+*.ori
142
+*.orig
143
+*.tmp
144
+

+ 3
- 0
config_example/config.py Dosyayı Görüntüle

@@ -6,6 +6,9 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
6 6
 # General settings
7 7
 #
8 8
 
9
+# APP_NAME is used for logging
10
+APP_NAME = 'pygal'
11
+
9 12
 # SECURITY WARNING: don't run with debug turned on in production!
10 13
 # DEBUG = False
11 14
 

+ 1
- 1
fstools

@@ -1 +1 @@
1
-Subproject commit ada1f74d4c05a35bad9d2b258f3d0b4ccdfd1653
1
+Subproject commit f5da43b01631147dace87242a94227acfb3e9bc5

+ 1
- 1
geo

@@ -1 +1 @@
1
-Subproject commit f59b19ed1fd2a64735ca477fdb1fba24681e8879
1
+Subproject commit 11166bb27ad2335f7812fcb88c788397f5106751

+ 22
- 33
main/settings.py Dosyayı Görüntüle

@@ -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
     },

+ 1
- 1
media

@@ -1 +1 @@
1
-Subproject commit 0a67ebeb4810eb00f422745b4a21ee420fc31c85
1
+Subproject commit abcf63d02e866c3832d014c54f2a95acdfb7d304

+ 1
- 1
mycreole

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

+ 1
- 1
pygal

@@ -1 +1 @@
1
-Subproject commit 84206862234752932d7c30daf82807c1e9fff67a
1
+Subproject commit 114a82e1768d3fbf8a83afb61b2f19c271b8868b

+ 0
- 18
readme.txt Dosyayı Görüntüle

@@ -1,18 +0,0 @@
1
-1. Setupt venev
2
-  * virtualenv -p /usr/bin/python3 pygal-venv
3
-  * ln -s pygal-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. python manage.py migrate
8
-3. python manage.py createsuperuser
9
-4. Set SECRET:KEY in config.py
10
-5. Set ITEM_ROOT in config.py to your item target path, otherwise the example_data is used
11
-6. python manage.py collectstatic
12
-7. chgrp www-data . && chmod 770 .
13
-8. chgrp www-data db.sqlite3 && chmod 664 db.sqlite3
14
-9. chgrp www-data -R data
15
-9.1. find data -type d -exec chmod 775 "{}" \;
16
-9.2. find data -type f -exec chmod 664 "{}" \;
17
-
18
-x. Run server by command "python manage.py runserver 0.0.0.0:8000" or add App to apache

+ 1
- 1
stringtools

@@ -1 +1 @@
1
-Subproject commit d5f9931bcab942ac84d8f09b1559995da0d2676c
1
+Subproject commit c1d9cf49c34cc6c97cfb372eec4a30f0188181f9

+ 1
- 1
users

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

Loading…
İptal
Kaydet