Skip to content

Commit

Permalink
Make shutting up JP a little easier
Browse files Browse the repository at this point in the history
  • Loading branch information
matozoid committed Dec 1, 2017
1 parent 832edc3 commit 2bcc159
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import static com.github.javaparser.utils.CodeGenerationUtils.f;

/**
* To avoid dependencies on logging frameworks, we have invited yet another logging framework :-)
* To avoid dependencies on logging frameworks, we have invented yet another logging framework :-)
*/
public class Log {
/**
* This adapter logs to standard out and standard error.
*/
public static class DefaultAdapter implements Adapter {
@Override
public void info(String message) {
Expand Down Expand Up @@ -44,6 +47,23 @@ private void printStackTrace(Throwable throwable) {
}
}

/**
* This adapter logs nothing.
*/
public static class SilentAdapter implements Adapter {
@Override
public void info(String message) {
}

@Override
public void trace(String message) {
}

@Override
public void error(Throwable throwable, String f) {
}
}

public interface Adapter {

void info(String message);
Expand All @@ -58,10 +78,20 @@ public interface Adapter {

private static Adapter CURRENT_ADAPTER = new DefaultAdapter();

/**
* Change how logging is handled. You can set your own implementation that forwards to your logging library.
*/
public static void setAdapter(Adapter adapter) {
CURRENT_ADAPTER = adapter;
}

/**
* Stop logging from appearing.
*/
public static void beQuiet() {
setAdapter(new SilentAdapter());
}

/**
* For logging information that may help solving a problem.
*/
Expand Down

0 comments on commit 2bcc159

Please sign in to comment.