Skip to content

Commit 36a6d13

Browse files
committed
Merge pull request #360 from JLLeitschuh/fix/testsCreateMultipleLogFiles
Fixes tests creating multiple log files in home directory
2 parents f480c73 + 320776d commit 36a6d13

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

core/src/main/java/edu/wpi/grip/core/GRIPCoreModule.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@
2323
* A Guice {@link com.google.inject.Module} for GRIP's core package. This is where instances of {@link Pipeline},
2424
* {@link Palette}, {@link Project}, etc... are created.
2525
*/
26+
@SuppressWarnings("PMD.MoreThanOneLogger")
2627
public class GRIPCoreModule extends AbstractModule {
2728
private final Logger logger = Logger.getLogger(GRIPCoreModule.class.getName());
2829

2930
private final EventBus eventBus = new EventBus(this::onSubscriberException);
3031

31-
public GRIPCoreModule() {
32+
// This is in a static initialization block so that we don't create a ton of
33+
// log files when running tests
34+
static {
3235
//Set up the global level logger. This handles IO for all loggers.
33-
final Logger globalLogger = LogManager.getLogManager().getLogger("");//This is our global logger
36+
final Logger globalLogger = LogManager.getLogManager().getLogger("");
3437

3538
try {
3639
// Remove the default handlers that stream to System.err
@@ -69,7 +72,10 @@ public synchronized void publish(final LogRecord record) {
6972
} catch (IOException exception) {//Something happened setting up file IO
7073
throw new IllegalStateException("Failed to configure the Logger", exception);
7174
}
75+
}
7276

77+
public GRIPCoreModule() {
78+
// TODO: HACK! Don't assign the global thread handler to an instance method. Creates global state.
7379
Thread.setDefaultUncaughtExceptionHandler(this::onThreadException);
7480
}
7581

0 commit comments

Comments
 (0)