Skip to content

Commit

Permalink
Implemented fixes for JLine Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
fturizo committed Mar 26, 2019
1 parent 6488cbd commit c4e0777
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ public abstract class CLICommand implements PostConstruct {
};
private String manpageTokenValues[] = new String[manpageTokens.length];


static{
checkToDisableJLineLogging();
}

/**
* The name of the command.
* Initialized in the constructor.
Expand Down Expand Up @@ -1388,4 +1391,17 @@ private static void file2Set(String file, Set<String> set) {
e.printStackTrace();
}
}

private static void checkToDisableJLineLogging(){
if (Boolean.getBoolean("fish.payara.admin.command.jline.log.disable")) {
System.setProperty("jline.log.jul", "false");
final OutputStream noOpOutputStream = new OutputStream() {
@Override
public void write(int b) throws IOException {
//NO-OP
}
};
jline.internal.Log.setOutput(new PrintStream(noOpOutputStream));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ protected Collection<ParamModel> usageOptions() {
protected int executeCommand() throws CommandException, CommandValidationException {
ConsoleReader reader = null;
programOpts.setEcho(echo); // restore echo flag, saved in validate
try {
checkToDisableJLineLogging();
try {
if (file == null) {
System.out.println(strings.get("multimodeIntro"));
reader = new ConsoleReader(ASADMIN, System.in, System.out, null, encoding);
Expand Down Expand Up @@ -185,19 +184,6 @@ public void write(byte[] b, int off, int len) throws IOException {
}
}
}

private static void checkToDisableJLineLogging(){
if (Boolean.getBoolean("fish.payara.admin.command.jline.log.disable")) {
System.setProperty("jline.log.jul", "false");
final OutputStream noOpOutputStream = new OutputStream() {
@Override
public void write(int b) throws IOException {
//NO-OP
}
};
jline.internal.Log.setOutput(new PrintStream(noOpOutputStream));
}
}

private static void atomicReplace(ServiceLocator locator, ProgramOptions options) {
DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
Expand Down

0 comments on commit c4e0777

Please sign in to comment.