Skip to content

Commit

Permalink
improved logging around BP and pulse logs to include readingDate, for #…
Browse files Browse the repository at this point in the history
  • Loading branch information
OHSUCMP committed Mar 11, 2024
1 parent a2f5cd6 commit b4f3428
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/main/java/edu/ohsu/cmp/coach/model/QuantityModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public void setUnit(String unit) {

@Override
public String toString() {
return value + unit;
return value + " " + unit;
}
}
21 changes: 13 additions & 8 deletions src/main/java/edu/ohsu/cmp/coach/service/BloodPressureService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand All @@ -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;
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/edu/ohsu/cmp/coach/service/PulseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand All @@ -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;
Expand Down

0 comments on commit b4f3428

Please sign in to comment.