Skip to content

Commit 615eb93

Browse files
committed
Java 5 classes for Logging Utils
1 parent e60c773 commit 615eb93

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

log-utils/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ Logging Utils uses a single, static logger to log messages to be used primarily
1010
- Delegate to a `PrintStream` object (for things like `Throwable#printStackTrace`) using `#getLog` or similar.
1111
- If a level is not being logged (i.e. lower than `Log.enabled`), an empty print stream is returned that will ignore all method calls.
1212
- Each level's `PrintStream` also exists as a public static final field, such as `Log.WARN`.
13-
- Java 6.
13+
- Java 5.
1414
- No config files, no managers, no bullshit.

log-utils/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ apply from: rootProject.file('build_shared.gradle')
1010

1111
java {
1212
toolchain.languageVersion = JavaLanguageVersion.of(6)
13+
sourceCompatibility = JavaVersion.VERSION_1_5
14+
targetCompatibility = JavaVersion.VERSION_1_5
15+
1316
withSourcesJar()
1417
withJavadocJar()
1518
}

log-utils/src/main/java/net/minecraftforge/util/logging/DelegatePrintStream.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
import java.util.Locale;
1010

1111
class DelegatePrintStream extends PrintStream {
12-
static final PrintStream EMPTY = new DelegatePrintStream(null, System.err) {
12+
static final PrintStream EMPTY = new EmptyPrintStream();
13+
private static final class EmptyPrintStream extends DelegatePrintStream {
14+
EmptyPrintStream() {
15+
super(null, System.err);
16+
}
17+
1318
@Override
1419
boolean isEnabled() {
1520
return false;
@@ -20,9 +25,9 @@ public boolean checkError() {
2025
return false;
2126
}
2227

23-
@SuppressWarnings({"unused", "ProtectedMemberInFinalClass", "override", "RedundantSuppression"})
28+
@SuppressWarnings({"unused", "override", "Since15"})
2429
protected void clearError() { }
25-
};
30+
}
2631

2732
private final Log.Level level;
2833
private boolean shouldIndent;

log-utils/src/main/java/net/minecraftforge/util/logging/Log.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public final class Log {
3232
/** The lowest level that should be logged. If {@code null}, all logging is completely disabled. */
3333
public static Level enabled = Level.INFO;
3434

35+
@SuppressWarnings({"unchecked", "rawtypes"}) // Java 5 restrictions
3536
private static final EnumMap<Level, PrintStream> STREAMS = new EnumMap(Level.class);
3637

3738
/** The stream used for {@link Level#DEBUG}. */

0 commit comments

Comments
 (0)