From b4f3428ebba6198c6dddfd58b5476e51c92b17b1 Mon Sep 17 00:00:00 2001 From: Matthew Storer Date: Mon, 11 Mar 2024 10:59:08 -0700 Subject: [PATCH] improved logging around BP and pulse logs to include readingDate, for #185 --- .../ohsu/cmp/coach/model/QuantityModel.java | 2 +- .../coach/service/BloodPressureService.java | 21 ++++++++++++------- .../ohsu/cmp/coach/service/PulseService.java | 18 +++++++++------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/main/java/edu/ohsu/cmp/coach/model/QuantityModel.java b/src/main/java/edu/ohsu/cmp/coach/model/QuantityModel.java index 98f09e9c..d83be9e0 100644 --- a/src/main/java/edu/ohsu/cmp/coach/model/QuantityModel.java +++ b/src/main/java/edu/ohsu/cmp/coach/model/QuantityModel.java @@ -37,6 +37,6 @@ public void setUnit(String unit) { @Override public String toString() { - return value + unit; + return value + " " + unit; } } diff --git a/src/main/java/edu/ohsu/cmp/coach/service/BloodPressureService.java b/src/main/java/edu/ohsu/cmp/coach/service/BloodPressureService.java index 35931707..ee00552f 100644 --- a/src/main/java/edu/ohsu/cmp/coach/service/BloodPressureService.java +++ b/src/main/java/edu/ohsu/cmp/coach/service/BloodPressureService.java @@ -133,14 +133,18 @@ public BloodPressureModel create(String sessionId, BloodPressureModel bpm) throw workspace.getRemoteBloodPressures().add(bpm2); } - auditService.doAudit(sessionId, AuditLevel.INFO, "wrote BP remotely", bpm.getSystolic() + "/" + bpm.getDiastolic()); + auditService.doAudit(sessionId, AuditLevel.INFO, "wrote BP remotely", bpm.getSystolic() + "/" + + bpm.getDiastolic() + " at " + bpm.getReadingDateString()); } catch (Exception e) { // remote errors are tolerable, since we will always store locally too - logger.warn("caught " + e.getClass().getSimpleName() + " attempting to create BP remotely - " + e.getMessage(), e); + logger.warn("caught " + e.getClass().getSimpleName() + " attempting to create BP remotely - " + + "BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic() + " at " + bpm.getReadingDateString() + + ", message=" + e.getMessage(), e); - auditService.doAudit(sessionId, AuditLevel.WARN, "failed to write BP remotely", - "BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic() + ", message=" + e.getMessage()); + auditService.doAudit(sessionId, AuditLevel.WARN, "failed to write BP remotely", "BP=" + + bpm.getSystolic() + "/" + bpm.getDiastolic() + " at " + bpm.getReadingDateString() + + ", message=" + e.getMessage()); } } @@ -153,14 +157,15 @@ public BloodPressureModel create(String sessionId, BloodPressureModel bpm) throw } auditService.doAudit(sessionId, AuditLevel.INFO, "created BP", "id=" + response.getId() + - ", BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic()); + ", BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic() + " at " + bpm.getReadingDateString()); } catch (DataException de) { // okay if it's failing to write locally, that's a problem. - logger.error("caught " + de.getClass().getName() + " attempting to create BloodPressureModel " + bpm); + logger.error("caught " + de.getClass().getName() + " attempting to create BloodPressureModel " + bpm, de); - auditService.doAudit(sessionId, AuditLevel.ERROR, "failed to create BP", - "BP=" + bpm.getSystolic() + "/" + bpm.getDiastolic() + ", message=" + de.getMessage()); + auditService.doAudit(sessionId, AuditLevel.ERROR, "failed to create BP", "BP=" + + bpm.getSystolic() + "/" + bpm.getDiastolic() + " at " + bpm.getReadingDateString() + + ", message=" + de.getMessage()); } return bpm2; diff --git a/src/main/java/edu/ohsu/cmp/coach/service/PulseService.java b/src/main/java/edu/ohsu/cmp/coach/service/PulseService.java index 76dea02e..fc133a70 100644 --- a/src/main/java/edu/ohsu/cmp/coach/service/PulseService.java +++ b/src/main/java/edu/ohsu/cmp/coach/service/PulseService.java @@ -122,14 +122,18 @@ public PulseModel create(String sessionId, PulseModel pm) throws DataException, workspace.getRemotePulses().add(pm2); } - auditService.doAudit(sessionId, AuditLevel.INFO, "wrote pulse remotely", String.valueOf(pm.getPulse())); + auditService.doAudit(sessionId, AuditLevel.INFO, "wrote pulse remotely", pm.getPulse() + + " at " + pm.getReadingDateString()); } catch (Exception e) { // remote errors are tolerable, since we will always store locally too - logger.warn("caught " + e.getClass().getSimpleName() + " attempting to create Pulse remotely - " + e.getMessage(), e); + logger.warn("caught " + e.getClass().getSimpleName() + " attempting to create Pulse remotely - " + + "pulse=" + pm.getPulse() + " at " + pm.getReadingDateString() + + ", message=" + e.getMessage(), e); auditService.doAudit(sessionId, AuditLevel.WARN, "failed to write pulse remotely", - "pulse=" + pm.getPulse() + ", message=" + e.getMessage()); + "pulse=" + pm.getPulse() + " at " + pm.getReadingDateString() + + ", message=" + e.getMessage()); } } @@ -142,14 +146,14 @@ public PulseModel create(String sessionId, PulseModel pm) throws DataException, } auditService.doAudit(sessionId, AuditLevel.INFO, "created pulse", "id=" + response.getId() + - ", pulse=" + pm.getPulse()); + ", pulse=" + pm.getPulse() + " at " + pm.getReadingDateString()); } catch (DataException de) { // okay if it's failing to write locally, that's a problem. - logger.error("caught " + de.getClass().getName() + " attempting to create PulseModel " + pm); + logger.error("caught " + de.getClass().getName() + " attempting to create PulseModel " + pm, de); - auditService.doAudit(sessionId, AuditLevel.ERROR, "failed to create pulse", - "pulse=" + pm.getPulse() + ", message=" + de.getMessage()); + auditService.doAudit(sessionId, AuditLevel.ERROR, "failed to create pulse", "pulse=" + + pm.getPulse() + " at " + pm.getReadingDateString() + ", message=" + de.getMessage()); } return pm2;