Skip to content

Commit

Permalink
use SLF4J formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ceki committed Feb 28, 2017
1 parent 97472ca commit 2f06933
Show file tree
Hide file tree
Showing 4 changed files with 736 additions and 737 deletions.
82 changes: 41 additions & 41 deletions slf4j-simple/src/main/java/org/slf4j/impl/OutputChoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,46 @@
*/
class OutputChoice {

enum OutputChoiceType {
SYS_OUT, CACHED_SYS_OUT, SYS_ERR, CACHED_SYS_ERR, FILE;
}

final OutputChoiceType outputChoiceType;
final PrintStream targetPrintStream;

OutputChoice(OutputChoiceType outputChoiceType) {
if (outputChoiceType == OutputChoiceType.FILE) {
throw new IllegalArgumentException();
}
this.outputChoiceType = outputChoiceType;
if (outputChoiceType == OutputChoiceType.CACHED_SYS_OUT) {
this.targetPrintStream = System.out;
} else if (outputChoiceType == OutputChoiceType.CACHED_SYS_ERR) {
this.targetPrintStream = System.err;
} else {
this.targetPrintStream = null;
}
}

OutputChoice(PrintStream printStream) {
this.outputChoiceType = OutputChoiceType.FILE;
this.targetPrintStream = printStream;
}

PrintStream getTargetPrintStream() {
switch (outputChoiceType) {
case SYS_OUT:
return System.out;
case SYS_ERR:
return System.err;
case CACHED_SYS_ERR:
case CACHED_SYS_OUT:
case FILE:
return targetPrintStream;
default:
throw new IllegalArgumentException();
}

}
enum OutputChoiceType {
SYS_OUT, CACHED_SYS_OUT, SYS_ERR, CACHED_SYS_ERR, FILE;
}

final OutputChoiceType outputChoiceType;
final PrintStream targetPrintStream;

OutputChoice(OutputChoiceType outputChoiceType) {
if (outputChoiceType == OutputChoiceType.FILE) {
throw new IllegalArgumentException();
}
this.outputChoiceType = outputChoiceType;
if (outputChoiceType == OutputChoiceType.CACHED_SYS_OUT) {
this.targetPrintStream = System.out;
} else if (outputChoiceType == OutputChoiceType.CACHED_SYS_ERR) {
this.targetPrintStream = System.err;
} else {
this.targetPrintStream = null;
}
}

OutputChoice(PrintStream printStream) {
this.outputChoiceType = OutputChoiceType.FILE;
this.targetPrintStream = printStream;
}

PrintStream getTargetPrintStream() {
switch (outputChoiceType) {
case SYS_OUT:
return System.out;
case SYS_ERR:
return System.err;
case CACHED_SYS_ERR:
case CACHED_SYS_OUT:
case FILE:
return targetPrintStream;
default:
throw new IllegalArgumentException();
}

}

}
Loading

0 comments on commit 2f06933

Please sign in to comment.