Skip to content

Commit

Permalink
fix: editing log statements
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Peterson <[email protected]>
  • Loading branch information
mattp-swirldslabs committed Aug 5, 2024
1 parent b44b41f commit 7411668
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ void singleBlock(
singleBlockResponseStreamObserver.onNext(
buildSingleBlockResponse(blockOpt.get()));
} else {
LOGGER.log(System.Logger.Level.INFO, "Block number {0} not found", blockNumber);
LOGGER.log(
System.Logger.Level.DEBUG, "Block number {0} not found", blockNumber);
singleBlockResponseStreamObserver.onNext(buildSingleBlockNotFoundResponse());
}
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public ConsumerBlockItemObserver(
isResponsePermitted.set(false);
subscriptionHandler.unsubscribe(this);
LOGGER.log(
System.Logger.Level.INFO,
System.Logger.Level.DEBUG,
"Consumer cancelled stream. Observer unsubscribed.");
};
serverCallStreamObserver.setOnCancelHandler(onCancel);
Expand All @@ -92,7 +92,7 @@ public ConsumerBlockItemObserver(
isResponsePermitted.set(false);
subscriptionHandler.unsubscribe(this);
LOGGER.log(
System.Logger.Level.INFO,
System.Logger.Level.DEBUG,
"Consumer completed stream. Observer unsubscribed.");
};
serverCallStreamObserver.setOnCloseHandler(onClose);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public void publish(final BlockItem blockItem) throws IOException {
serviceStatus.setRunning(false);
LOGGER.log(
System.Logger.Level.ERROR,
"An exception occurred while attempting to persist the BlockItem: {0}",
blockItem,
"An exception occurred while attempting to persist the BlockItem: "
+ blockItem,
e);

LOGGER.log(System.Logger.Level.INFO, "Send a response to end the stream");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ private boolean isPathDisqualified(final Path path) {
return true;
}
} catch (IOException e) {
LOGGER.log(System.Logger.Level.ERROR, "Error setting permissions on: " + path, e);
LOGGER.log(
System.Logger.Level.ERROR, "Error setting permissions on: {0}" + path, e);
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public void remove(final long id) throws IOException {
// for removal
final Path blockPath = blockNodeRootPath.resolve(String.valueOf(id));
if (Files.notExists(blockPath)) {
LOGGER.log(System.Logger.Level.ERROR, "Block does not exist: " + id);
LOGGER.log(System.Logger.Level.ERROR, "Block does not exist: {0}", id);
return;
}

Files.setPosixFilePermissions(blockPath, filePerms.value());

// Best effort to delete the block
if (!delete(blockPath.toFile())) {
LOGGER.log(System.Logger.Level.ERROR, "Failed to delete block: " + id);
LOGGER.log(System.Logger.Level.ERROR, "Failed to delete block: {0}", id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void write(final BlockItem blockItem) throws IOException {

LOGGER.log(
System.Logger.Level.ERROR,
"Error writing the BlockItem protobuf to a file",
"Error writing the BlockItem protobuf to a file: ",
e);

// Remove the block if repairing the permissions fails
Expand Down Expand Up @@ -144,7 +144,9 @@ protected void write(final Path blockItemFilePath, final BlockItem blockItem)
blockItemFilePath);
} catch (IOException e) {
LOGGER.log(
System.Logger.Level.ERROR, "Error writing the BlockItem protobuf to a file", e);
System.Logger.Level.ERROR,
"Error writing the BlockItem protobuf to a file: ",
e);
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void onNext(final PublishStreamRequest publishStreamRequest) {
} catch (IOException | NoSuchAlgorithmException e) {
final var errorResponse = buildErrorStreamResponse();
publishStreamResponseObserver.onNext(errorResponse);
LOGGER.log(System.Logger.Level.ERROR, "Error calculating hash", e);
LOGGER.log(System.Logger.Level.ERROR, "Error calculating hash: ", e);
}

} else {
Expand All @@ -106,7 +106,7 @@ public void onNext(final PublishStreamRequest publishStreamRequest) {
} catch (IOException io) {
final var errorResponse = buildErrorStreamResponse();
publishStreamResponseObserver.onNext(errorResponse);
LOGGER.log(System.Logger.Level.ERROR, "Exception thrown publishing BlockItem", io);
LOGGER.log(System.Logger.Level.ERROR, "Exception thrown publishing BlockItem: ", io);

LOGGER.log(System.Logger.Level.ERROR, "Shutting down the web server");
serviceStatus.stopWebServer();
Expand Down Expand Up @@ -136,7 +136,7 @@ private static PublishStreamResponse buildErrorStreamResponse() {
*/
@Override
public void onError(final Throwable t) {
LOGGER.log(System.Logger.Level.ERROR, "onError method invoked with an exception", t);
LOGGER.log(System.Logger.Level.ERROR, "onError method invoked with an exception: ", t);
publishStreamResponseObserver.onError(t);
}

Expand Down

0 comments on commit 7411668

Please sign in to comment.