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

Move the blocking log operation to executor thread #284

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion core/main/java/com/codingchili/core/logging/LogMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import io.vertx.core.json.JsonObject;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static com.codingchili.core.configuration.CoreStrings.*;

/**
Expand All @@ -10,6 +13,7 @@
public class LogMessage {
private Logger logger;
private JsonObject event;
private final ExecutorService executor = Executors.newSingleThreadExecutor();

/**
* Creates a new logging message. Constructor typically invoked indirectly
Expand Down Expand Up @@ -50,7 +54,9 @@ public LogMessage put(String key, Object value) {
* @return the logger that was used to send the message.
*/
public Logger send() {
logger.log(event);
executor.execute(() -> {
logger.log(event);
});
return logger;
}

Expand Down