mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	logging: Skip log records originated in site packages.
This fixes the huge exception we get in our logs from django.template logger. This exception is a known bug in Django, see https://code.djangoproject.com/ticket/26886 Fixes #3974
This commit is contained in:
		@@ -73,3 +73,12 @@ def skip_200_and_304(record):
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    return True
 | 
			
		||||
 | 
			
		||||
def skip_site_packages_logs(record):
 | 
			
		||||
    # type: (logging.LogRecord) -> bool
 | 
			
		||||
    # This skips the log records that are generated from libraries
 | 
			
		||||
    # installed in site packages.
 | 
			
		||||
    # Workaround for https://code.djangoproject.com/ticket/26886
 | 
			
		||||
    if 'site-packages' in record.pathname:
 | 
			
		||||
        return False
 | 
			
		||||
    return True
 | 
			
		||||
 
 | 
			
		||||
@@ -992,6 +992,10 @@ LOGGING = {
 | 
			
		||||
            '()': 'django.utils.log.CallbackFilter',
 | 
			
		||||
            'callback': zerver.lib.logging_util.skip_200_and_304,
 | 
			
		||||
        },
 | 
			
		||||
        'skip_site_packages_logs': {
 | 
			
		||||
            '()': 'django.utils.log.CallbackFilter',
 | 
			
		||||
            'callback': zerver.lib.logging_util.skip_site_packages_logs,
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    'handlers': {
 | 
			
		||||
        'zulip_admins': {
 | 
			
		||||
@@ -1062,7 +1066,7 @@ LOGGING = {
 | 
			
		||||
        },
 | 
			
		||||
        'django.template': {
 | 
			
		||||
            'handlers': ['console'],
 | 
			
		||||
            'filters': ['require_debug_true'],
 | 
			
		||||
            'filters': ['require_debug_true', 'skip_site_packages_logs'],
 | 
			
		||||
            'level': 'DEBUG',
 | 
			
		||||
            'propagate': False,
 | 
			
		||||
        },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user