Skip to content

Commit

Permalink
pw_transfer: Reduce Java client log verbosity
Browse files Browse the repository at this point in the history
Disable a few logs and lower the log level of some others.

Change-Id: Ie12d56830a9a08375010cf427aebe1736d5daad9
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/124671
Pigweed-Auto-Submit: Wyatt Hepler <[email protected]>
Reviewed-by: Alexei Frolov <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
255 authored and CQ Bot Account committed Dec 16, 2022
1 parent dcba7d5 commit 3df488e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void handleDataChunk(VersionedChunk chunk) throws TransferAbortedExceptio
remainingWindowSize <= parameters.maxPendingBytes() / EXTEND_WINDOW_DIVISOR;

if (remainingWindowSize == 0) {
logger.atFiner().log(
logger.atFinest().log(
"%s received all pending bytes; sending transfer parameters update", ReadTransfer.this);
sendChunk(prepareTransferParameters(/*extend=*/false));
} else if (extendWindow) {
Expand Down
9 changes: 7 additions & 2 deletions pw_transfer/java/main/dev/pigweed/pw_transfer/Transfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ abstract class Transfer<T> {
// Largest nanosecond instant. Used to block indefinitely when no transfers are pending.
static final Instant NO_TIMEOUT = Instant.ofEpochSecond(0, Long.MAX_VALUE);

// Whether to output some particularly noisy logs.
static final boolean VERBOSE_LOGGING = false;

private final int resourceId;
private final ProtocolVersion desiredProtocolVersion;
private final TransferEventHandler.TransferInterface eventHandler;
Expand Down Expand Up @@ -277,7 +280,9 @@ final void sendChunk(VersionedChunk chunk) throws TransferAbortedException {
}

try {
logger.atFinest().log("%s sending %s", this, chunk);
if (VERBOSE_LOGGING) {
logger.atFinest().log("%s sending %s", this, chunk);
}
eventHandler.sendChunk(chunk.toMessage());
} catch (TransferError transferError) {
changeState(new Completed(transferError));
Expand Down Expand Up @@ -305,7 +310,7 @@ final void updateProgress(long bytesSent, long bytesConfirmedReceived, long tota
long durationNanos = Duration.between(startTime, Instant.now()).toNanos();
long totalRate = durationNanos == 0 ? 0 : (bytesSent * 1_000_000_000 / durationNanos);

logger.atFine().log("%s progress: "
logger.atFiner().log("%s progress: "
+ "%5.1f%% (%d B sent, %d B confirmed received of %s B total) at %d B/s",
this,
progress.percentReceived(),
Expand Down
14 changes: 8 additions & 6 deletions pw_transfer/java/main/dev/pigweed/pw_transfer/WriteTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ public void handleTimeout() throws TransferAbortedException {
ByteString chunkData = ByteString.copyFrom(
data, sentOffset, min(windowEndOffset - sentOffset, maxChunkSizeBytes));

logger.atFiner().log("%s sending bytes %d-%d (%d B chunk, max size %d B)",
WriteTransfer.this,
sentOffset,
sentOffset + chunkData.size() - 1,
chunkData.size(),
maxChunkSizeBytes);
if (VERBOSE_LOGGING) {
logger.atFinest().log("%s sending bytes %d-%d (%d B chunk, max size %d B)",
WriteTransfer.this,
sentOffset,
sentOffset + chunkData.size() - 1,
chunkData.size(),
maxChunkSizeBytes);
}

sendChunk(buildDataChunk(chunkData));

Expand Down

0 comments on commit 3df488e

Please sign in to comment.