File: logging.py

package info (click to toggle)
django-maintenance-mode 0.16.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 188 kB
  • sloc: python: 499; makefile: 4
file content (25 lines) | stat: -rw-r--r-- 620 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from django.conf import settings

from maintenance_mode.core import get_maintenance_mode

import logging


class RequireNotMaintenanceMode503(logging.Filter):
    """
    Filters out 503 errors if maintenance mode is activated.
    """

    def filter(self, record):
        """
        Return False if maintenance mode is on and
        the given record has a status code of 503.
        """
        status_code = getattr(record, 'status_code', None)
        if get_maintenance_mode() and status_code == 503:
            return False
        return True