Skip to content

Commit

Permalink
Merge pull request #1573 from ScilifelabDataCentre/DDS-2176-Maintenan…
Browse files Browse the repository at this point in the history
…ceOngoingException

MaintenanceOngoingException
  • Loading branch information
rv0lt authored Dec 3, 2024
2 parents 5aec387 + 7fc7883 commit 0954097
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,5 @@ _Nothing merged during this sprint_

# 2024-12-02 - 2024-12-13

- Bugfix: Quick and dirty change to prevent `dds ls --tree` from failing systematically ([#1575](https://github.com/ScilifelabDataCentre/dds_web/pull/1575).
- Filter out the MaintenanceModeException from the logs ([#1573](https://github.com/ScilifelabDataCentre/dds_web/pull/1573))
- Bugfix: Quick and dirty change to prevent `dds ls --tree` from failing systematically ([#1575](https://github.com/ScilifelabDataCentre/dds_web/pull/1575)
17 changes: 17 additions & 0 deletions dds_web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@
####################################################################################################


class FilterMaintenanceExc(logging.Filter):

def filter(record):
"""
Filters log records to exclude those with MaintenanceOngoingException.
Returns:
bool: True if the log record should be logged, False if it should be filtered out.
"""
from dds_web.errors import MaintenanceOngoingException

# 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 +178,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 0954097

Please sign in to comment.