Skip to content

Commit

Permalink
add filter to exception
Browse files Browse the repository at this point in the history
  • Loading branch information
rv0lt committed Nov 7, 2024
1 parent 197f7ed commit 386e6f0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dds_web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from flask_httpauth import HTTPBasicAuth, HTTPTokenAuth
import flask_mail
import flask_login
from flask.logging import logging as flask_logging
import flask_migrate


Expand Down Expand Up @@ -68,6 +69,14 @@
####################################################################################################


class FilterMaintenanceExc(flask_logging.Filter):
from dds_web.errors import MaintenanceOngoingException

def filter(record):
# Check if the log record does not have an exception or if the exception is not MaintenanceOngoingException
return record.exc_info is None or record.exc_info[0] != MaintenanceOngoingException


def setup_logging(app):
"""Setup loggers"""

Expand Down Expand Up @@ -164,6 +173,9 @@ def action_wrapper(_, __, event_dict):
cache_logger_on_first_use=True,
)

# Add custom filter to the logger
logging.getLogger("general").addFilter(FilterMaintenanceExc)


def create_app(testing=False, database_uri=None):
try:
Expand Down

0 comments on commit 386e6f0

Please sign in to comment.