@@ -37,19 +37,19 @@ public final class Log {
37
37
/** The lowest level that should be logged. If {@code null}, all logging is completely disabled. */
38
38
public static @ Nullable Level enabled = Level .INFO ;
39
39
40
- public static final PrintStream EMPTY = EmptyPrintStream . INSTANCE ;
40
+ public static final PrintStream EMPTY = DelegatePrintStream . EMPTY ;
41
41
/** The stream used for {@link Level#DEBUG}. */
42
- public static final PrintStream DEBUG = CapturingPrintStream . of (Level .DEBUG , System .out :: println );
42
+ public static final PrintStream DEBUG = new DelegatePrintStream . Capturing (Level .DEBUG , System .out );
43
43
/** The stream used for {@link Level#QUIET}. */
44
- public static final PrintStream QUIET = CapturingPrintStream . of (Level .QUIET , System .out :: println );
44
+ public static final PrintStream QUIET = new DelegatePrintStream . Capturing (Level .QUIET , System .out );
45
45
/** The stream used for {@link Level#INFO}. */
46
- public static final PrintStream INFO = CapturingPrintStream . of (Level .INFO , System .out :: println );
46
+ public static final PrintStream INFO = new DelegatePrintStream . Capturing (Level .INFO , System .out );
47
47
/** The stream used for {@link Level#WARN}. */
48
- public static final PrintStream WARN = CapturingPrintStream . of (Level .WARN , System .out :: println );
48
+ public static final PrintStream WARN = new DelegatePrintStream . Capturing (Level .WARN , System .out );
49
49
/** The stream used for {@link Level#ERROR}. */
50
- public static final PrintStream ERROR = CapturingPrintStream . of (Level .ERROR , System .err :: println );
50
+ public static final PrintStream ERROR = new DelegatePrintStream . Capturing (Level .ERROR , System .err );
51
51
/** The stream used for {@link Level#FATAL}. */
52
- public static final PrintStream FATAL = CapturingPrintStream . of (Level .FATAL , System .err :: println );
52
+ public static final PrintStream FATAL = new DelegatePrintStream . Capturing (Level .FATAL , System .err );
53
53
54
54
55
55
/* INDENTATIONS */
@@ -104,10 +104,10 @@ private static String getIndentation(byte indent) {
104
104
static @ UnknownNullability List <CapturedMessage > CAPTURED ;
105
105
106
106
private static final class CapturedMessage {
107
- private final Log . Level level ;
107
+ private final Level level ;
108
108
private final String message ;
109
109
110
- private CapturedMessage (Log . Level level , String message ) {
110
+ private CapturedMessage (Level level , String message ) {
111
111
this .level = level ;
112
112
this .message = message ;
113
113
}
@@ -134,7 +134,7 @@ public static void capture() {
134
134
CAPTURED = new ArrayList <>(128 );
135
135
}
136
136
137
- static void tryCapture (Consumer <String > logger , Log . Level level , String message ) {
137
+ static void tryCapture (Consumer <String > logger , Level level , String message ) {
138
138
if (CAPTURED != null )
139
139
CAPTURED .add (new CapturedMessage (level , message ));
140
140
else
@@ -157,7 +157,7 @@ public static void drop() {
157
157
* @see #release(BiConsumer)
158
158
*/
159
159
public static void release () {
160
- release (Log ::logInternal );
160
+ release (Log ::logCaptured );
161
161
}
162
162
163
163
/**
@@ -166,7 +166,7 @@ public static void release() {
166
166
* @param consumer The consumer to release the captured log messages to
167
167
* @see #capture()
168
168
*/
169
- public static void release (BiConsumer <Log . Level , String > consumer ) {
169
+ public static void release (BiConsumer <Level , String > consumer ) {
170
170
if (CAPTURED == null ) return ;
171
171
172
172
Iterator <CapturedMessage > itor = CAPTURED .iterator ();
@@ -178,8 +178,8 @@ public static void release(BiConsumer<Log.Level, String> consumer) {
178
178
}
179
179
180
180
// so we can use a method reference instead of allocate a lambda
181
- private static void logInternal (Level level , String message ) {
182
- Log .log (level , message );
181
+ private static void logCaptured (Level level , String message ) {
182
+ (( DelegatePrintStream ) Log .getLog (level )). getDelegate (). println ( message );
183
183
}
184
184
185
185
0 commit comments