Selaa lähdekoodia

Logging for own loggers enabled in config

master
Dirk Alders 3 kuukautta sitten
vanhempi
commit
12fbbcedf8
1 muutettua tiedostoa jossa 37 lisäystä ja 0 poistoa
  1. 37
    0
      piki/settings.py

+ 37
- 0
piki/settings.py Näytä tiedosto

@@ -148,6 +148,43 @@ USE_I18N = True
148 148
 
149 149
 USE_TZ = True
150 150
 
151
+# Logging Configuration
152
+#
153
+LOGGING = {
154
+    'version': 1,
155
+    'disable_existing_loggers': False,
156
+    'formatters': {
157
+        'short': {
158
+            'format': "%(name)25s - %(levelname)10s - %(message)s",
159
+            'datefmt': '[%d/%b/%Y %H:%M:%S]',
160
+        },
161
+        'long': {
162
+            'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163
+File "%(pathname)s", line %(lineno)d, in %(funcName)s
164
+%(asctime)s: %(name)s - %(message)s
165
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
166
+        },
167
+    },
168
+    'handlers': {
169
+        'console': {
170
+            'level': 'DEBUG',
171
+            'class': 'logging.StreamHandler',
172
+            'formatter': 'short',
173
+        },
174
+    },
175
+    'loggers': {
176
+        'django': {
177
+            'handlers': ['console'],
178
+            'level': 'INFO',
179
+            'propagate': False,
180
+        },
181
+        ROOT_LOGGER_NAME: {
182
+            'handlers': ['console'],
183
+            'level': 'DEBUG' if DEBUG else 'INFO',
184
+            'propagate': False,
185
+        },
186
+    },
187
+}
151 188
 
152 189
 # Static files (CSS, JavaScript, Images)
153 190
 # https://docs.djangoproject.com/en/5.1/howto/static-files/

Loading…
Peruuta
Tallenna