Skip to content

Commit ab2563d

Browse files
committed
make sure the Statistics is always reported
1 parent f0aede7 commit ab2563d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -439,29 +439,30 @@ public HistoryEntry getLastHistoryEntry(File file, boolean ui) throws HistoryExc
439439
if (history != null) {
440440
HistoryEntry lastHistoryEntry = history.getLastHistoryEntry();
441441
if (lastHistoryEntry != null) {
442-
LOGGER.log(Level.FINEST, "got latest history entry {0} for ''{1}'' from history cache",
443-
new Object[]{lastHistoryEntry, file});
442+
statistics.report(LOGGER, Level.FINEST,
443+
String.format("got latest history entry %s for ''%s'' from history cache",
444+
lastHistoryEntry, file), "history.entry.latest");
444445
return lastHistoryEntry;
445446
}
446447
}
447448
} catch (CacheException e) {
448-
LOGGER.log(Level.FINER, e.getMessage());
449+
LOGGER.log(Level.FINER,
450+
String.format("failed to retrieve last history entry for ''%s'' in %s using history cache",
451+
file, repository),
452+
e.getMessage());
449453
}
450454

451455
if (!isRepoHistoryEligible(repository, file, ui)) {
452-
LOGGER.log(Level.FINER, "cannot retrieve the last history entry for ''{0}'' in {1} because of settings",
453-
new Object[]{file, repository});
456+
statistics.report(LOGGER, Level.FINEST,
457+
String.format("cannot retrieve the last history entry for ''%s'' in %s because of settings",
458+
file, repository), "history.entry.latest");
454459
return null;
455460
}
456461

457462
// Fallback to the repository method.
458463
HistoryEntry lastHistoryEntry = repository.getLastHistoryEntry(file, ui);
459-
if (lastHistoryEntry != null) {
460-
LOGGER.log(Level.FINEST, "got latest history entry {0} for ''{1}'' using repository {2}",
461-
new Object[]{lastHistoryEntry, file, repository});
462-
}
463464
statistics.report(LOGGER, Level.FINEST,
464-
String.format("finished retrieval of last history entry for '%s' (%s)",
465+
String.format("finished retrieval of last history entry for '%s' using repository method (%s)",
465466
file, lastHistoryEntry != null ? "success" : "fail"), "history.entry.latest");
466467
return lastHistoryEntry;
467468
}

0 commit comments

Comments
 (0)