Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of Optional for logging messages in setupShutdownHookForReplayer #7

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,16 @@ private static void setupShutdownHookForReplayer(TrafficReplayerTopLevel tr) {
// both Log4J and the java builtin loggers add shutdown hooks.
// The API for addShutdownHook says that those hooks registered will run in an undetermined order.
// Hence, the reason that this code logs via slf4j logging AND stderr.
Optional.of("Running TrafficReplayer Shutdown. "
+ "The logging facilities may also be shutting down concurrently, "
+ "resulting in missing logs messages.")
.ifPresent(beforeMsg -> {
log.atWarn().setMessage(beforeMsg).log();
System.err.println(beforeMsg);
});
var beforeMsg = "Running TrafficReplayer Shutdown. "
+ "The logging facilities may also be shutting down concurrently, "
+ "resulting in missing logs messages.";
log.atWarn().setMessage(beforeMsg).log();
System.err.println(beforeMsg);
Optional.ofNullable(weakTrafficReplayer.get()).ifPresent(o -> o.shutdown(null));
Optional.of("Done shutting down TrafficReplayer (due to Runtime shutdown). "
+ "Logs may be missing for events that have happened after the Shutdown event was received.")
.ifPresent(afterMsg -> {
log.atWarn().setMessage(afterMsg).log();
System.err.println(afterMsg);
});
var afterMsg = "Done shutting down TrafficReplayer (due to Runtime shutdown). "
+ "Logs may be missing for events that have happened after the Shutdown event was received.";
log.atWarn().setMessage(afterMsg).log();
System.err.println(afterMsg);
}));
}

Expand Down
Loading