-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jorrit Poelen
committed
Jul 29, 2024
1 parent
a6fb626
commit ee04b9e
Showing
2 changed files
with
61 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/org/globalbioticinteractions/elton/cmd/ReviewReportLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.globalbioticinteractions.elton.cmd; | ||
|
||
import org.eol.globi.data.ImportLogger; | ||
import org.eol.globi.domain.LogContext; | ||
import org.globalbioticinteractions.elton.util.ProgressCursorFactory; | ||
import org.globalbioticinteractions.elton.util.ProgressUtil; | ||
|
||
import java.io.PrintStream; | ||
|
||
public class ReviewReportLogger implements ImportLogger { | ||
private final ReviewReport report; | ||
private final PrintStream stdout; | ||
private final Long maxLines; | ||
private final ProgressCursorFactory factory; | ||
|
||
public ReviewReportLogger(ReviewReport report, PrintStream stdout, Long maxLines, ProgressCursorFactory factory) { | ||
this.report = report; | ||
this.stdout = stdout; | ||
this.maxLines = maxLines; | ||
this.factory = factory; | ||
} | ||
|
||
|
||
@Override | ||
public void info(LogContext ctx, String message) { | ||
logWithCounter(ctx, message, ReviewCommentType.info); | ||
report.getInfoCounter().incrementAndGet(); | ||
} | ||
|
||
@Override | ||
public void warn(LogContext ctx, String message) { | ||
logWithCounter(ctx, message, ReviewCommentType.note); | ||
report.getNoteCounter().incrementAndGet(); | ||
} | ||
|
||
@Override | ||
public void severe(LogContext ctx, String message) { | ||
logWithCounter(ctx, message, ReviewCommentType.note); | ||
report.getNoteCounter().incrementAndGet(); | ||
} | ||
|
||
private void logWithCounter(LogContext ctx, String message, ReviewCommentType commentType) { | ||
if (this.maxLines == null || report.getLineCount().get() < this.maxLines) { | ||
CmdReview.log(ctx, message, commentType, report, stdout); | ||
} | ||
|
||
long l = report.getLineCount().incrementAndGet(); | ||
if (l % ProgressUtil.LOG_ACTIVITY_PROGRESS_BATCH_SIZE == 0) { | ||
factory.createProgressCursor().increment(); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |