Skip to content

Commit 6fe7ebb

Browse files
committed
add timeClock logging
1 parent 2a22a94 commit 6fe7ebb

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/main/java/de/focusshift/zeiterfassung/timeclock/TimeClockService.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ public TimeClock updateTimeClock(UserId userId, TimeClockUpdate timeClockUpdate)
108108

109109
final TimeClockEntity timeClockEntity = toEntity(timeClock);
110110

111+
LOG.info("Updating TimeClock for user {}", userId.value());
112+
LOG.debug("Next TimeClock: {}", timeClock);
113+
111114
return toTimeClock(timeClockRepository.save(timeClockEntity));
112115
}
113116

@@ -121,14 +124,16 @@ void stopTimeClock(UserId userId) {
121124
.map(entity -> timeClockEntityWithStoppedAt(entity, ZonedDateTime.now(userSettingsProvider.zoneId())))
122125
.map(timeClockRepository::save)
123126
.map(TimeClockService::toTimeClock)
124-
.ifPresent(timeClock -> {
125-
126-
final ZonedDateTime start = timeClock.startedAt();
127-
final ZonedDateTime end = timeClock.stoppedAt()
128-
.orElseThrow(() -> new IllegalStateException("expected stoppedAt to contain a value."));
129-
130-
timeEntryService.createTimeEntry(userId, timeClock.comment(), start, end, timeClock.isBreak());
131-
});
127+
.ifPresentOrElse(
128+
timeClock -> {
129+
final ZonedDateTime start = timeClock.startedAt();
130+
final ZonedDateTime end = timeClock.stoppedAt()
131+
.orElseThrow(() -> new IllegalStateException("expected stoppedAt to contain a value."));
132+
133+
LOG.info("Stopping TimeClock={} for user={} and creating TimeEntry for it.", timeClock.id(), userId.value());
134+
timeEntryService.createTimeEntry(userId, timeClock.comment(), start, end, timeClock.isBreak());
135+
},
136+
() -> LOG.info("Not stopping TimeClock for user {} since nothing found. No TimeEntry created.", userId.value()));
132137
}
133138

134139
private static TimeClockEntity toEntity(TimeClock timeClock) {

0 commit comments

Comments
 (0)