Skip to content

Commit

Permalink
simplify logic on when to show which message
Browse files Browse the repository at this point in the history
  • Loading branch information
sclassen committed Jul 9, 2020
1 parent 5cc3b7d commit d6b0490
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
import java.util.List;
import java.util.regex.Pattern;

import static net.sourceforge.jnlp.util.logging.OutputControllerLevel.DEBUG;
import static net.sourceforge.jnlp.util.logging.OutputControllerLevel.ERROR;
import static net.sourceforge.jnlp.util.logging.OutputControllerLevel.INFO;
import static net.sourceforge.jnlp.util.logging.OutputControllerLevel.WARN;

public class ConsoleOutputPaneModel {

ConsoleOutputPaneModel(ObservableMessagesProvider dataProvider) {
Expand Down Expand Up @@ -97,17 +102,19 @@ String importList(boolean mark, int start, int sortByLocal) {


if (mark) {
final Header header = messageWithHeader.getHeader();
final OutputControllerLevel level = header.level;
sb.append("<div style='color:#");
if (messageWithHeader.getHeader().isClientApp) {
if (messageWithHeader.getHeader().level.printToErrStream()) {
if (header.isClientApp) {
if (level == ERROR) {
sb.append(HTMLCOLOR_PURPLE);
} else {
sb.append(HTMLCOLOR_GREEN);
}
} else {
if (messageWithHeader.getHeader().level.isWarning()) {
if (level == WARN) {
sb.append(HTMLCOLOR_GREENYELLOW);
} else if (messageWithHeader.getHeader().level.printToErrStream()) {
} else if (level == ERROR) {
sb.append(HTMLCOLOR_PINKYREAD);
} else {
sb.append(HTMLCOLOR_BLACK);
Expand Down Expand Up @@ -254,16 +261,16 @@ boolean filtered(MessageWithHeader m) {
final Header header = m.getHeader();
final OutputControllerLevel level = header.level;

if (!showOut && level.printToOutStream() && !level.isWarning()) {
if (!showOut && !level.printToErrStream()) {
return true;
}
if (!showErr && level.printToErrStream() && !level.isWarning()) {
if (!showErr && !level.printToOutStream()) {
return true;
}
if (!showDebug && level.isDebug()) {
if (!showDebug && level == DEBUG) {
return true;
}
if (!showInfo && level.isInfo()) {
if (!showInfo && level == INFO) {
return true;
}
if (!showItw && !header.isClientApp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
import java.util.LinkedList;
import java.util.List;

import static net.sourceforge.jnlp.util.logging.OutputControllerLevel.DEBUG;
import static net.sourceforge.jnlp.util.logging.OutputControllerLevel.ERROR;
import static net.sourceforge.jnlp.util.logging.OutputControllerLevel.WARN;

/**
* OutputController class (thread) must NOT call JNLPRuntime.getConfiguration()
*/
Expand Down Expand Up @@ -123,7 +127,7 @@ private void consumeItwMessage(MessageWithHeader message) {
final Header header = message.getHeader();
final OutputControllerLevel level = header.level;

if (!JNLPRuntime.isDebug() && (level.isDebug())) {
if (!JNLPRuntime.isDebug() && level == DEBUG) {
return;
}

Expand All @@ -144,7 +148,7 @@ private void consumeItwMessage(MessageWithHeader message) {

//only crucial stuff is going to system log
//only java messages handled here, plugin is on his own
if (logConfig.isLogToSysLog() && level.isCrucial()) {
if (logConfig.isLogToSysLog() && (level == ERROR || level == WARN)) {
//no headers here
getSystemLog().log(message.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,10 @@ public enum OutputControllerLevel {
;

public boolean printToOutStream() {
return this == INFO
|| this == DEBUG
|| this == WARN;
return this == INFO || this == DEBUG || this == WARN;
}

public boolean printToErrStream() {
return this == ERROR
|| this == WARN;
}

public boolean isWarning() {
return this == WARN;
}

public boolean isDebug() {
return this == DEBUG;
}

public boolean isInfo() {
return this == ERROR
|| this == WARN
|| this == INFO;
}

public boolean isCrucial() {
return this == ERROR
|| this == WARN;
return this == ERROR || this == WARN;
}
}

0 comments on commit d6b0490

Please sign in to comment.