Skip to content

Commit

Permalink
add ability to disable logging from ThrowableHandlers
Browse files Browse the repository at this point in the history
  • Loading branch information
katepol committed Nov 16, 2017
1 parent 0051f40 commit 470fd65
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ protected Boolean initialValue() {
}
};

@SuppressWarnings("NonJREEmulationClassesInClientCode")
private static final ThreadLocal<Boolean> LOGGING_ENABLED = new ThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() {
return Boolean.TRUE;
}
};

@SuppressWarnings("NonJREEmulationClassesInClientCode")
private static final ThreadLocal<MyEventSource> HANDLERS = new ThreadLocal<MyEventSource>() {
@Override
Expand Down Expand Up @@ -101,7 +109,7 @@ public static void handle(Throwable t) {
}

// ourForceProduction is used only in tests, where severe level is logged by default.
if (!FORCE_PRODUCTION.get()) {
if (!FORCE_PRODUCTION.get() && LOGGING_ENABLED.get()) {
LOG.log(Level.SEVERE, "Exception handled at ThrowableHandlers", t);
}
handleError(t);
Expand Down

0 comments on commit 470fd65

Please sign in to comment.