Skip to content

Commit

Permalink
Refactor - eliminate non-constant string concatenation from debug and…
Browse files Browse the repository at this point in the history
… trace (hyperledger#7336)

* eliminate non-constant string concatenation from debug and trace

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* adjustments

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
macfarla committed Jul 18, 2024
1 parent cee973d commit 39e276f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion besu/src/main/java/org/hyperledger/besu/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private void waitForServiceToStop(final String serviceName, final SynchronousShu
try {
shutdown.await();
} catch (final InterruptedException e) {
LOG.debug("Interrupted while waiting for service " + serviceName + " to stop", e);
LOG.debug("Interrupted while waiting for service {} to stop {}", serviceName, e);
Thread.currentThread().interrupt();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void onBlockAdded(final BlockAddedEvent event) {
if (event.isNewCanonicalHead() && blocksToBePruned >= pruningFrequency) {
long currentRetainedBlock = blockNumber - currentPruningMark + 1;
while (currentRetainedBlock > blocksToRetain) {
LOG.debug("Pruning chain data with block height of " + currentPruningMark);
LOG.debug("Pruning chain data with block height of {}", currentPruningMark);
pruneChainDataAtBlock(pruningTransaction, currentPruningMark);
currentPruningMark++;
currentRetainedBlock = blockNumber - currentPruningMark;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ Optional<MutableWorldState> rollMutableStateToBlockHash(
} catch (final Exception e) {
// if we fail we must clean up the updater
diffBasedUpdater.reset();
LOG.debug(
"State rolling failed on "
+ mutableState.getWorldStateStorage().getClass().getSimpleName()
+ " for block hash "
+ blockHash,
e);
LOG.atDebug()
.setMessage("State rolling failed on {} for block hash {}")
.addArgument(mutableState.getWorldStateStorage().getClass().getSimpleName())
.addArgument(blockHash)
.addArgument(e)
.log();

return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,11 @@ private int compareDuplicateConnections(final PeerConnection a, final PeerConnec
}
}
// Otherwise, keep older connection
LOG.trace("comparing timestamps " + a.getInitiatedAt() + " with " + b.getInitiatedAt());
LOG.atTrace()
.setMessage("comparing timestamps {} with {}")
.addArgument(a.getInitiatedAt())
.addArgument(b.getInitiatedAt())
.log();
return a.getInitiatedAt() < b.getInitiatedAt() ? -1 : 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,18 @@ private <T> CompletableFuture<T> timeout(

public void stop() {
if (stopped.compareAndSet(false, true)) {
LOG.trace("Stopping " + getClass().getSimpleName());
LOG.atTrace().setMessage("Stopping {}").addArgument(getClass().getSimpleName()).log();
syncWorkerExecutor.shutdownNow();
txWorkerExecutor.shutdownNow();
scheduler.shutdownNow();
servicesExecutor.shutdownNow();
computationExecutor.shutdownNow();
shutdown.countDown();
} else {
LOG.trace("Attempted to stop already stopped " + getClass().getSimpleName());
LOG.atTrace()
.setMessage("Attempted to stop already stopped {}")
.addArgument(getClass().getSimpleName())
.log();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void processMessage(final Capability cap, final Message message) {
final EthPeer ethPeer = ethPeers.peer(message.getConnection());
if (ethPeer == null) {
LOG.debug(
"Ignoring message received from unknown peer connection: " + message.getConnection());
"Ignoring message received from unknown peer connection: {}", message.getConnection());
return;
}
final EthMessage ethMessage = new EthMessage(ethPeer, messageData);
Expand Down Expand Up @@ -132,9 +132,10 @@ public void processMessage(final Capability cap, final Message message) {
try {
ethPeer.send(responseData, getSupportedProtocol());
} catch (final PeerConnection.PeerNotConnected error) {
// Peer disconnected before we could respond - nothing to do
LOG.trace(
"Peer disconnected before we could respond - nothing to do " + error.getMessage());
LOG.atTrace()
.setMessage("Peer disconnected before we could respond - nothing to do {}")
.addArgument(error.getMessage())
.log();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ public UpnpNatManager() {
new BesuUpnpRegistryListener() {
@Override
public void remoteDeviceAdded(final Registry registry, final RemoteDevice device) {
LOG.debug("UPnP Device discovered: " + device.getDetails().getFriendlyName());
LOG.atDebug()
.setMessage("UPnP Device discovered: {}")
.addArgument(device.getDetails().getFriendlyName())
.log();
inspectDeviceRecursive(device, recognizedServices.keySet());
}
};
Expand Down

0 comments on commit 39e276f

Please sign in to comment.