Skip to content

Commit

Permalink
Add show_debug notification (#5101)
Browse files Browse the repository at this point in the history
Co-authored-by: Lorenzo Gaifas <brisvag@gmail.com>
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
  • Loading branch information
3 people authored and Czaki committed Nov 13, 2023
1 parent f9dc828 commit 5b1b193
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions napari/utils/_tests/test_notification_manager.py
Expand Up @@ -9,6 +9,7 @@
from napari.utils.notifications import (
Notification,
notification_manager,
show_debug,
show_error,
show_info,
show_warning,
Expand Down Expand Up @@ -91,6 +92,10 @@ def test_notification_manager_no_gui(monkeypatch):
assert len(notification_manager.records) == 6
assert store[-1].type == 'warning'

show_debug('This is a debug')
assert len(notification_manager.records) == 7
assert store[-1].type == 'debug'

# make sure we've restored the except hook
assert sys.excepthook == previous_exhook

Expand Down
11 changes: 11 additions & 0 deletions napari/utils/notifications.py
Expand Up @@ -37,7 +37,9 @@ def _noop(*_, **__):
'ErrorNotification',
'WarningNotification',
'NotificationManager',
'show_debug',
'show_info',
'show_warning',
'show_error',
'show_console_notification',
]
Expand Down Expand Up @@ -332,6 +334,15 @@ def receive_info(self, message: str):
notification_manager = NotificationManager()


def show_debug(message: str):
"""
Show a debug message in the notification manager.
"""
notification_manager.dispatch(
Notification(message, severity=NotificationSeverity.DEBUG)
)


def show_info(message: str):
"""
Show an info message in the notification manager.
Expand Down

0 comments on commit 5b1b193

Please sign in to comment.