Skip to content

Commit 094a9b1

Browse files
committed
add more logging for last revision retrieval
1 parent e83b889 commit 094a9b1

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,19 @@ private History getHistoryFromCache(File file, Repository repository, boolean wi
254254
/**
255255
* @param file file to get the history entry for
256256
* @param ui is the request coming from the UI
257-
* @return last (newest) history entry for given file or null
257+
* @return last (newest) history entry for given file or {@code null}
258258
* @throws HistoryException if history retrieval failed
259259
*/
260260
@Nullable
261261
public HistoryEntry getLastHistoryEntry(File file, boolean ui) throws HistoryException {
262+
Statistics statistics = new Statistics();
263+
LOGGER.log(Level.FINEST, "started retrieval of last history entry for ''{0}''", file);
262264
final File dir = file.isDirectory() ? file : file.getParentFile();
263265
final Repository repository = getRepository(dir);
264266

265267
if (!isRepoHistoryEligible(repository, file, ui)) {
268+
LOGGER.log(Level.FINER, "cannot retrieve the last history entry for ''{0}'' in {1} because of settings",
269+
new Object[]{file, repository});
266270
return null;
267271
}
268272

@@ -282,7 +286,15 @@ public HistoryEntry getLastHistoryEntry(File file, boolean ui) throws HistoryExc
282286
return null;
283287
}
284288

285-
return repository.getLastHistoryEntry(file, ui);
289+
HistoryEntry lastHistoryEntry = repository.getLastHistoryEntry(file, ui);
290+
if (lastHistoryEntry != null) {
291+
LOGGER.log(Level.FINEST, "got latest history entry {0} for ''{1}'' using repository {2}",
292+
new Object[]{lastHistoryEntry, file, repository});
293+
}
294+
statistics.report(LOGGER, Level.FINEST,
295+
String.format("finished retrieval of last history entry for '%s' (%s)",
296+
file, lastHistoryEntry != null ? "success" : "fail"), "history.lasthistoryentry");
297+
return lastHistoryEntry;
286298
}
287299

288300
public History getHistory(File file, boolean withFiles, boolean ui) throws HistoryException {

opengrok-web/src/main/java/org/opengrok/web/PageConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,12 +1291,15 @@ public File findDataFile() {
12911291
@Nullable
12921292
public String getLatestRevision() {
12931293
if (!getEnv().isHistoryEnabled()) {
1294+
LOGGER.log(Level.FINE, "will not get latest revision for ''{0}'' as history is disabled",
1295+
getResourceFile());
12941296
return null;
12951297
}
12961298

12971299
// Try getting the history revision from the index first.
12981300
String lastRev = getLastRevFromIndex();
12991301
if (lastRev != null) {
1302+
LOGGER.log(Level.FINEST, "got last revision of ''{0}'' from the index", getResourceFile());
13001303
return lastRev;
13011304
}
13021305

@@ -1305,7 +1308,7 @@ public String getLatestRevision() {
13051308
try {
13061309
return getLastRevFromHistory();
13071310
} catch (HistoryException e) {
1308-
LOGGER.log(Level.WARNING, "cannot get latest revision for {0}", getPath());
1311+
LOGGER.log(Level.WARNING, "cannot get latest revision for ''{0}'' using history", getPath());
13091312
return null;
13101313
}
13111314
}

0 commit comments

Comments
 (0)