Skip to content

Commit 9387465

Browse files
authored
Merge pull request #59 from dihm/improved_error_logging
Improved error logging
2 parents 8024cfa + 9862954 commit 9387465

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

runviewer/__main__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import pprint
3535
import signal
3636
import concurrent.futures
37+
import traceback
3738

3839
splash.update_text('importing labscript suite modules')
3940
from labscript_utils.setup_logging import setup_logging
@@ -762,6 +763,7 @@ def on_shot_selection_changed(self, item):
762763
self.on_toggle_shutter(item.checkState(), current_shot)
763764

764765
def load_shot(self, filepath):
766+
logger.info(f'loading run from {filepath:s}')
765767
shot = Shot(filepath)
766768

767769
# add shot to shot list
@@ -1533,7 +1535,7 @@ def add_shutter_times(self, shutters):
15331535

15341536
def _load_device(self, device, clock=None):
15351537
try:
1536-
print('loading %s' % device.name)
1538+
logger.info('loading %s' % device.name)
15371539
module = device.device_class
15381540
# Load the master pseudoclock class
15391541
device_class = device_registry.get_runviewer_parser(module)
@@ -1545,15 +1547,14 @@ def _load_device(self, device, clock=None):
15451547
for grandchild_device_name, grandchild_device in child_device.child_list.items():
15461548
self._load_device(grandchild_device, trace)
15471549

1548-
except Exception:
1549-
# TODO: print/log exception traceback
1550-
# if device.name == 'ni_card_0' or device.name == 'pulseblaster_0' or device.name == 'pineblaster_0' or device.name == 'ni_card_1' or device.name == 'novatechdds9m_0':
1551-
# raise
1552-
# raise
1550+
except Exception as e:
1551+
15531552
if hasattr(device, 'name'):
1554-
print('Failed to load device %s' % device.name)
1553+
logger.info(f'Failed to load device {device.name:s}, exception was:\n'+
1554+
''.join(traceback.format_exception(type(e), e, e.__traceback__)))
15551555
else:
1556-
print('Failed to load device (unknown name, device object does not have attribute name)')
1556+
logger.info('Failed to load device (unknown name, device object does not have attribute name), exception was:\n'+
1557+
''.join(traceback.format_exception(type(e), e, e.__traceback__)))
15571558

15581559
# backwards compat
15591560
with h5py.File(self.path, 'r') as file:

0 commit comments

Comments
 (0)