16
16
17
17
from os .path import normpath , join , dirname , abspath
18
18
from dbmi_client import environment
19
+ from dbmi_client import reporting
20
+ from dbmi_client .logging import config
19
21
20
22
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
21
23
BASE_DIR = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
301
303
302
304
#####################################################################################
303
305
304
- LOGGING = {
305
- 'version' : 1 ,
306
- 'disable_existing_loggers' : False ,
307
- 'formatters' : {
308
- 'console' : {
309
- 'format' : '[HYPATIO] - [%(asctime)s][%(levelname)s][%(name)s.%(funcName)s:%(lineno)d] - %(message)s' ,
310
- },
306
+ #####################################################################################
307
+ # Logging settings
308
+ #####################################################################################
309
+
310
+ # Configure Sentry
311
+ reporting .sentry (
312
+ sentry_dsn = environment .get_str ("SENTRY_DSN" , required = True ),
313
+ release = f'{ environment .get_str ("DBMI_APP_NAME" )} @{ environment .get_str ("DBMI_APP_VERSION" )} ' ,
314
+ environment = environment .get_str ("DBMI_ENV" , "prod" ),
315
+ sentry_trace_rate = environment .get_float ("SENTRY_TRACES_RATE" , default = 0.0 ),
316
+ sentry_profile_rate = environment .get_float ("SENTRY_PROFILES_RATE" , default = 0.0 ),
317
+ )
318
+
319
+ # Output the standard logging configuration
320
+ LOGGING = config ('HYPATIO' , root_level = logging .DEBUG )
321
+
322
+ # Disable warning level for 4xx request logging
323
+ LOGGING ['loggers' ].update ({
324
+ 'django.request' : {
325
+ 'handlers' : ['console' ],
326
+ 'level' : 'ERROR' ,
327
+ 'propagate' : True ,
311
328
},
312
- 'handlers' : {
313
- 'sentry' : {
314
- 'level' : 'ERROR' ,
315
- 'class' : 'raven.contrib.django.raven_compat.handlers.SentryHandler' ,
316
- },
317
- 'console' : {
318
- 'level' : 'DEBUG' ,
319
- 'class' : 'logging.StreamHandler' ,
320
- 'formatter' : 'console' ,
321
- 'stream' : sys .stdout ,
322
- },
329
+ 'boto3' : {
330
+ 'handlers' : ['console' ],
331
+ 'level' : 'INFO' ,
332
+ 'propagate' : True ,
323
333
},
324
- 'root' : {
325
- 'handlers' : ['console' , ],
326
- 'level' : 'DEBUG'
334
+ 'botocore' : {
335
+ 'handlers' : ['console' ],
336
+ 'level' : 'INFO' ,
337
+ 'propagate' : True ,
327
338
},
328
- 'loggers' : {
329
- 'django' : {
330
- 'handlers' : ['console' , ],
331
- 'level' : 'INFO' ,
332
- 'propagate' : True ,
333
- },
334
- 'raven' : {
335
- 'level' : 'WARNING' ,
336
- 'handlers' : ['console' ],
337
- 'propagate' : False ,
338
- },
339
- 'sentry.errors' : {
340
- 'level' : 'WARNING' ,
341
- 'handlers' : ['console' ],
342
- 'propagate' : False ,
343
- },
344
- 'botocore' : {
345
- 'level' : 'WARNING' ,
346
- 'handlers' : ['console' ],
347
- 'propagate' : True ,
348
- },
349
- 'boto3' : {
350
- 'level' : 'WARNING' ,
351
- 'handlers' : ['console' ],
352
- 'propagate' : True ,
353
- },
354
- 's3transfer' : {
355
- 'level' : 'WARNING' ,
356
- 'handlers' : ['console' ],
357
- 'propagate' : True ,
358
- },
339
+ 's3transfer' : {
340
+ 'handlers' : ['console' ],
341
+ 'level' : 'INFO' ,
342
+ 'propagate' : True ,
359
343
},
360
- }
344
+ 'urllib3' : {
345
+ 'handlers' : ['console' ],
346
+ 'level' : 'INFO' ,
347
+ 'propagate' : True ,
348
+ },
349
+ })
361
350
362
- RAVEN_CONFIG = {
363
- 'dsn' : environment .get_str ("RAVEN_URL" , required = True ),
364
- # If you are using git, you can also automatically configure the
365
- # release based on the git info.
366
- 'release' : '1' ,
367
- 'site' : 'HYPATIO'
368
- }
351
+ #####################################################################################
0 commit comments