diff --git a/daq/src/aaredaq/aaredb.py b/daq/src/aaredaq/aaredb.py index ace577b5..edb83f5b 100644 --- a/daq/src/aaredaq/aaredb.py +++ b/daq/src/aaredaq/aaredb.py @@ -171,7 +171,20 @@ class AareWrapper: sample_event_create=SampleEventCreate(event_type=SampleEventType("Lost")), ) except Exception as e: - print(e) + logger.error(f"Error sending message to db: {e}") + + def send_msg_to_db(self, s: Optional[SampleShortInfo], event_type:Optional[SampleEventType | str], comment: str = ''): + if s is None or event_type is None: + logger.debug(f"sample info or event type is None, skipping message: {event_type} {comment}") + return + if isinstance(event_type, str): + event_type = SampleEventType(event_type) + try: + self.__sample_api.create_sample_event( + sample_id=s.db_id, + sample_event_create=SampleEventCreate(event_type=event_type, comment=comment) + ) + except Exception as e: logger.error(f"Error sending message to db: {e}") def upload_image(self, sample_id: int, filename: str, bgr_image: np.ndarray):