Skip to content

Commit 6eeff5c

Browse files
committed
fixed VST debug logging
1 parent e6ba67a commit 6eeff5c

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

driver/src/main/java/com/arangodb/async/internal/velocystream/VstCommunicationAsync.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ protected CompletableFuture<InternalResponse> execute(final InternalRequest requ
6767
final CompletableFuture<InternalResponse> rfuture = new CompletableFuture<>();
6868
try {
6969
final Message message = createMessage(request);
70+
if (LOGGER.isDebugEnabled()) {
71+
String body = request.getBody() == null ? "" : util.toJsonString(request.getBody());
72+
LOGGER.debug("Send Request [id={}]: {} {}", message.getId(), request, body);
73+
}
7074
send(message, connection).whenComplete((m, ex) -> {
7175
if (m != null) {
7276
final InternalResponse response;
@@ -102,6 +106,10 @@ protected CompletableFuture<InternalResponse> execute(final InternalRequest requ
102106
} catch (ArangoDBException e) {
103107
rfuture.completeExceptionally(e);
104108
}
109+
if (LOGGER.isDebugEnabled()) {
110+
String body = response.getBody() == null ? "" : util.toJsonString(response.getBody());
111+
LOGGER.debug("Received Response [id={}]: {} {}", m.getId(), response, body);
112+
}
105113
rfuture.complete(response);
106114
} else if (ex != null) {
107115
LOGGER.error(ex.getMessage(), ex);
@@ -118,10 +126,6 @@ protected CompletableFuture<InternalResponse> execute(final InternalRequest requ
118126
}
119127

120128
private CompletableFuture<Message> send(final Message message, final VstConnectionAsync connection) {
121-
if (LOGGER.isDebugEnabled()) {
122-
LOGGER.debug(String.format("Send Message (id=%s, head=%s, body=%s)", message.getId(), message.getHead(),
123-
message.getBody() != null ? message.getBody() : "{}"));
124-
}
125129
return connection.write(message, buildChunks(message));
126130
}
127131

driver/src/main/java/com/arangodb/internal/velocystream/VstCommunicationSync.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ protected InternalResponse execute(final InternalRequest request, final VstConne
6262
protected InternalResponse execute(final InternalRequest request, final VstConnectionSync connection, final int attemptCount) {
6363
try {
6464
final Message requestMessage = createMessage(request);
65+
if (LOGGER.isDebugEnabled()) {
66+
String body = request.getBody() == null ? "" : util.toJsonString(request.getBody());
67+
LOGGER.debug("Send Request [id={}]: {} {}", requestMessage.getId(), request, body);
68+
}
6569
final Message responseMessage = send(requestMessage, connection);
6670
final InternalResponse response = createResponse(responseMessage);
71+
if (LOGGER.isDebugEnabled()) {
72+
String body = response.getBody() == null ? "" : util.toJsonString(response.getBody());
73+
LOGGER.debug("Received Response [id={}]: {} {}", responseMessage.getId(), response, body);
74+
}
6775
checkError(response);
6876
return response;
6977
} catch (final VPackParserException e) {
@@ -80,10 +88,6 @@ protected InternalResponse execute(final InternalRequest request, final VstConne
8088
}
8189

8290
private Message send(final Message message, final VstConnectionSync connection) {
83-
if (LOGGER.isDebugEnabled()) {
84-
LOGGER.debug(String.format("Send Message (id=%s, head=%s, body=%s)", message.getId(), message.getHead(),
85-
message.getBody() != null ? message.getBody() : "{}"));
86-
}
8791
return connection.write(message, buildChunks(message));
8892
}
8993

driver/src/main/java/com/arangodb/internal/velocystream/internal/MessageStore.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ public void storeMessage(final long messageId, final FutureTask<Message> future)
5454
public void consume(final Message message) {
5555
final FutureTask<Message> future = task.remove(message.getId());
5656
if (future != null) {
57-
if (LOGGER.isDebugEnabled()) {
58-
LOGGER.debug(String.format("Received Message (id=%s, head=%s, body=%s)", message.getId(),
59-
message.getHead(), message.getBody() != null ? message.getBody() : "{}"));
60-
}
6157
response.put(message.getId(), message);
6258
future.run();
6359
}

0 commit comments

Comments
 (0)