Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added command line option for log-level #1751

Merged
merged 8 commits into from
Jun 27, 2024
2 changes: 2 additions & 0 deletions cli/src/main/java/de/jplag/cli/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import de.jplag.JPlagResult;
import de.jplag.cli.logger.CliProgressBarProvider;
import de.jplag.cli.logger.CollectedLoggerFactory;
import de.jplag.cli.logger.JPlagLoggerBase;
import de.jplag.cli.picocli.CliInputHandler;
import de.jplag.exceptions.ExitException;
import de.jplag.logging.ProgressBarLogger;
Expand Down Expand Up @@ -45,6 +46,7 @@ public void executeCli() throws ExitException, IOException {
logger.debug("Your version of JPlag is {}", JPlag.JPLAG_VERSION);

if (!this.inputHandler.parse()) {
JPlagLoggerBase.currentLogLevel = this.inputHandler.getCliOptions().advanced.logLevel;
ProgressBarLogger.setProgressBarProvider(new CliProgressBarProvider());

switch (this.inputHandler.getCliOptions().mode) {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/de/jplag/cli/logger/CollectedLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CollectedLogger extends JPlagLoggerBase {
private final ConcurrentLinkedDeque<LogEntry> allErrors = new ConcurrentLinkedDeque<>();

public CollectedLogger(String name) {
super(LOG_LEVEL_INFO, name);
super(name);
}

@Override
Expand Down
6 changes: 2 additions & 4 deletions cli/src/main/java/de/jplag/cli/logger/JPlagLoggerBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ public abstract class JPlagLoggerBase extends AbstractLogger {

private static final Level LOG_LEVEL_FOR_EXTERNAL_LIBRARIES = LOG_LEVEL_ERROR;

private final Level currentLogLevel;
public static Level currentLogLevel = LOG_LEVEL_INFO;
TwoOfTwelve marked this conversation as resolved.
Show resolved Hide resolved

/**
* @param currentLogLevel The current log level
* @param name The name of the logger
*/
protected JPlagLoggerBase(Level currentLogLevel, String name) {
this.currentLogLevel = currentLogLevel;
protected JPlagLoggerBase(String name) {
this.name = name;
}

Expand Down
5 changes: 5 additions & 0 deletions cli/src/main/java/de/jplag/cli/options/CliOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.io.File;

import org.slf4j.event.Level;

import de.jplag.Language;
import de.jplag.clustering.ClusteringAlgorithm;
import de.jplag.clustering.ClusteringOptions;
Expand Down Expand Up @@ -98,6 +100,9 @@ public static class Advanced {

@Option(names = "--csv-export", description = "Export pairwise similarity values as a CSV file.")
public boolean csvExport = false;

@Option(names = "--log-level", description = "Set the log level for the cli.")
public Level logLevel = Level.INFO;
}

public static class Clustering {
Expand Down