Skip to content

Commit

Permalink
Invalid logger breaks current application flow
Browse files Browse the repository at this point in the history
if a invalid ansi logger configuration is given, swap to default sdt out
instead of throw an `IllegalStateException` exception
  • Loading branch information
pablo gonzalez granados committed May 7, 2021
1 parent 5238a13 commit 6c616bd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/src/main/java/io/dekorate/logger/AnsiLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import static org.fusesource.jansi.Ansi.*;
import static org.fusesource.jansi.Ansi.Color.*;


import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintStream;

import org.fusesource.jansi.*;
Expand All @@ -29,7 +32,7 @@

public class AnsiLogger extends LoggerFactory<PrintStream> implements Logger {

private final PrintStream stream;
private PrintStream stream;

public Logger create(PrintStream stream) {
return new AnsiLogger(stream);
Expand Down Expand Up @@ -79,7 +82,9 @@ public void error(String message) {

private void check() {
if (stream == null) {
throw new IllegalStateException("AnsiLogger requires a PrintStream instance.");
stream = new PrintStream(new FileOutputStream(FileDescriptor.out));
stream.println("Invalid AnsiLogger Stream -> Swapping to default sdt out logger.");
}
}

}

0 comments on commit 6c616bd

Please sign in to comment.