diff --git a/pw_transfer/java/main/dev/pigweed/pw_transfer/ReadTransfer.java b/pw_transfer/java/main/dev/pigweed/pw_transfer/ReadTransfer.java index 4834ff876f..15e3cd321e 100644 --- a/pw_transfer/java/main/dev/pigweed/pw_transfer/ReadTransfer.java +++ b/pw_transfer/java/main/dev/pigweed/pw_transfer/ReadTransfer.java @@ -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) { diff --git a/pw_transfer/java/main/dev/pigweed/pw_transfer/Transfer.java b/pw_transfer/java/main/dev/pigweed/pw_transfer/Transfer.java index 365bbba57e..fef83e59e2 100644 --- a/pw_transfer/java/main/dev/pigweed/pw_transfer/Transfer.java +++ b/pw_transfer/java/main/dev/pigweed/pw_transfer/Transfer.java @@ -34,6 +34,9 @@ abstract class Transfer { // 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; @@ -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)); @@ -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(), diff --git a/pw_transfer/java/main/dev/pigweed/pw_transfer/WriteTransfer.java b/pw_transfer/java/main/dev/pigweed/pw_transfer/WriteTransfer.java index d89ed8743b..daf5213f76 100644 --- a/pw_transfer/java/main/dev/pigweed/pw_transfer/WriteTransfer.java +++ b/pw_transfer/java/main/dev/pigweed/pw_transfer/WriteTransfer.java @@ -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));