Skip to content

Commit

Permalink
Review log formatting to use parameterized messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Nov 3, 2024
1 parent 1034b87 commit 3c8ad9c
Show file tree
Hide file tree
Showing 672 changed files with 1,965 additions and 1,990 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Path copy(final Path source, final Path copy, final TransferStatus status
final String id = target.startCopy(s,
AccessCondition.generateEmptyCondition(), AccessCondition.generateEmptyCondition(), options, context);
if(log.isDebugEnabled()) {
log.debug(String.format("Started copy for %s with copy operation ID %s", copy, id));
log.debug("Started copy for {} with copy operation ID {}", copy, id);
}
listener.sent(status.getLength());
return copy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public boolean find(Path file, final ListProgressListener listener) throws Backg
}
}
if(log.isDebugEnabled()) {
log.debug(String.format("Search for common prefix %s", file));
log.debug("Search for common prefix {}", file);
}
// Check for common prefix
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
for(ListBlobItem object : result.getResults()) {
if(new SimplePathPredicate(new Path(object.getUri().getPath(), EnumSet.of(Path.Type.directory))).test(directory)) {
if(log.isDebugEnabled()) {
log.debug(String.format("Skip placeholder key %s", object));
log.debug("Skip placeholder key {}", object);
}
hasDirectoryPlaceholder = true;
continue;
Expand All @@ -115,7 +115,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
while(result.getHasMoreResults());
if(!hasDirectoryPlaceholder && children.isEmpty()) {
if(log.isWarnEnabled()) {
log.warn(String.format("No placeholder found for directory %s", directory));
log.warn("No placeholder found for directory {}", directory);
}
throw new NotfoundException(directory.getAbsolute());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public InputStream read(final Path file, final TransferStatus status, final Conn
@Override
protected void handleIOException(final IOException e) throws IOException {
if(StringUtils.equals(SR.STREAM_CLOSED, e.getMessage())) {
log.warn(String.format("Ignore failure %s", e));
log.warn("Ignore failure {}", e);
return;
}
final Throwable cause = ExceptionUtils.getRootCause(e);
Expand Down
6 changes: 3 additions & 3 deletions azure/src/main/java/ch/cyberduck/core/azure/AzureSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void eventOccurred(final SendingRequestEvent event) {
switch(proxy.getType()) {
case SOCKS: {
if(log.isInfoEnabled()) {
log.info(String.format("Configured to use SOCKS proxy %s", proxyfinder));
log.info("Configured to use SOCKS proxy {}", proxyfinder);
}
final java.net.Proxy socksProxy = new java.net.Proxy(
java.net.Proxy.Type.SOCKS, new InetSocketAddress(proxy.getHostname(), proxy.getPort()));
Expand All @@ -136,7 +136,7 @@ public void eventOccurred(final SendingRequestEvent event) {
case HTTP:
case HTTPS: {
if(log.isInfoEnabled()) {
log.info(String.format("Configured to use HTTP proxy %s", proxyfinder));
log.info("Configured to use HTTP proxy {}", proxyfinder);
}
final java.net.Proxy httpProxy = new java.net.Proxy(
java.net.Proxy.Type.HTTP, new InetSocketAddress(proxy.getHostname(), proxy.getPort()));
Expand Down Expand Up @@ -167,7 +167,7 @@ public void login(final LoginCallback prompt, final CancelCallback cancel) throw
// Success
}
catch(NotfoundException e) {
log.warn(String.format("Ignore failure %s", e));
log.warn("Ignore failure {}", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public StatusOutputStream<Void> write(final Path file, final TransferStatus stat
@Override
protected void handleIOException(final IOException e) throws IOException {
if(StringUtils.equals(SR.STREAM_CLOSED, e.getMessage())) {
log.warn(String.format("Ignore failure %s", e));
log.warn("Ignore failure {}", e);
return;
}
final Throwable cause = ExceptionUtils.getRootCause(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public PathAttributes find(final Path file, final ListProgressListener listener)
// Throw failure if latest version has hide marker set and lookup was without explicit version
if(StringUtils.isBlank(file.attributes().getVersionId())) {
if(log.isDebugEnabled()) {
log.debug(String.format("Latest version of %s is duplicate", file));
log.debug("Latest version of {} is duplicate", file);
}
throw new NotfoundException(file.getAbsolute());
}
Expand Down Expand Up @@ -142,7 +142,7 @@ public PathAttributes toAttributes(final BaseB2Response response) {
if(response instanceof B2FinishLargeFileResponse) {
return this.toAttributes((B2FinishLargeFileResponse) response);
}
log.error(String.format("Unknown type %s", response));
log.error("Unknown type {}", response);
return PathAttributes.EMPTY;
}

Expand All @@ -165,7 +165,7 @@ protected PathAttributes toAttributes(final B2FileInfoResponse response) {
attributes.setModificationDate(Long.parseLong(value));
}
catch(NumberFormatException e) {
log.warn(String.format("Failure parsing src_last_modified_millis with value %s", value));
log.warn("Failure parsing src_last_modified_millis with value {}", value);
}
}
else {
Expand All @@ -177,7 +177,7 @@ protected PathAttributes toAttributes(final B2FileInfoResponse response) {
attributes.setCreationDate(Long.parseLong(value));
}
catch(NumberFormatException e) {
log.warn(String.format("Failure parsing src_creation_date_millis with value %s", value));
log.warn("Failure parsing src_creation_date_millis with value {}", value);
}
}
if(response.getAction() != null) {
Expand Down Expand Up @@ -216,7 +216,7 @@ protected PathAttributes toAttributes(final B2FileResponse response) {
attributes.setModificationDate(Long.parseLong(value));
}
catch(NumberFormatException e) {
log.warn(String.format("Failure parsing src_last_modified_millis with value %s", value));
log.warn("Failure parsing src_last_modified_millis with value {}", value);
}
}
else {
Expand All @@ -228,7 +228,7 @@ protected PathAttributes toAttributes(final B2FileResponse response) {
attributes.setCreationDate(Long.parseLong(value));
}
catch(NumberFormatException e) {
log.warn(String.format("Failure parsing src_creation_date_millis with value %s", value));
log.warn("Failure parsing src_creation_date_millis with value {}", value);
}
}
if(response.getAction() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public DescriptiveUrl toDownloadUrl(final Path file, final Sharee sharee, final
URIEncoder.encode(containerService.getKey(file)));
try {
if(log.isDebugEnabled()) {
log.debug(String.format("Create download authorization for %s", file));
log.debug("Create download authorization for {}", file);
}
final int seconds = 604800;
// Determine expiry time for URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void delete(final Map<Path, TransferStatus> files, final PasswordCallback
placeholder = fileid.getVersionId(file);
}
catch(NotfoundException e) {
log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e, file));
log.warn("Ignore failure {} deleting placeholder file for {}", e, file);
continue;
}
if(null == placeholder) {
Expand All @@ -82,7 +82,7 @@ public void delete(final Map<Path, TransferStatus> files, final PasswordCallback
session.getClient().deleteFileVersion(containerService.getKey(file), placeholder);
}
catch(B2ApiException e) {
log.warn(String.format("Ignore failure %s deleting placeholder file for %s", e.getMessage(), file));
log.warn("Ignore failure {} deleting placeholder file for {}", e.getMessage(), file);
}
catch(IOException e) {
throw new DefaultIOExceptionMappingService().map("Cannot delete {0}", e, file);
Expand All @@ -93,14 +93,14 @@ else if(file.isFile()) {
if(!versioning.isEnabled() || null == file.attributes().getVersionId()) {
// Add hide marker
if(log.isDebugEnabled()) {
log.debug(String.format("Add hide marker %s of %s", file.attributes().getVersionId(), file));
log.debug("Add hide marker {} of {}", file.attributes().getVersionId(), file);
}
try {
session.getClient().hideFile(fileid.getVersionId(containerService.getContainer(file)), containerService.getKey(file));
}
catch(B2ApiException e) {
if("already_hidden".equalsIgnoreCase(e.getCode())) {
log.warn(String.format("Ignore failure %s hiding file %s already hidden", e.getMessage(), file));
log.warn("Ignore failure {} hiding file {} already hidden", e.getMessage(), file);
}
else {
throw e;
Expand All @@ -110,7 +110,7 @@ else if(file.isFile()) {
else {
// Delete specific version
if(log.isDebugEnabled()) {
log.debug(String.format("Delete version %s of %s", file.attributes().getVersionId(), file));
log.debug("Delete version {} of {}", file.attributes().getVersionId(), file);
}
session.getClient().deleteFileVersion(containerService.getKey(file), file.attributes().getVersionId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public boolean retryRequest(final HttpResponse response, final int executionCoun
return true;
}
catch(B2ApiException | IOException e) {
log.warn(String.format("Attempt to renew expired auth token failed. %s", e.getMessage()));
log.warn("Attempt to renew expired auth token failed. {}", e.getMessage());
}
}
}
}
catch(IOException e) {
log.warn(String.format("Failure parsing response entity from %s", response));
log.warn("Failure parsing response entity from {}", response);
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public Path copy(final Path source, final Path target, final TransferStatus stat
// Submit to queue
parts.add(this.submit(pool, source, response.getFileId(), status, partNumber, offset, length, callback));
if(log.isDebugEnabled()) {
log.debug(String.format("Part %s submitted with size %d and offset %d", partNumber, length, offset));
log.debug("Part {} submitted with size {} and offset {}", partNumber, length, offset);
}
remaining -= length;
offset += length;
Expand All @@ -130,7 +130,7 @@ public int compare(final B2UploadPartResponse o1, final B2UploadPartResponse o2)
}
session.getClient().finishLargeFileUpload(response.getFileId(), checksums.toArray(new String[checksums.size()]));
if(log.isInfoEnabled()) {
log.info(String.format("Finished large file upload %s with %d parts", target, completed.size()));
log.info("Finished large file upload {} with {} parts", target, completed.size());
}
fileid.cache(target, response.getFileId());
return target.withAttributes(new PathAttributes(source.attributes()).withVersionId(response.getFileId()));
Expand All @@ -151,7 +151,7 @@ private Future<B2UploadPartResponse> submit(final ThreadPool pool, final Path fi
final int partNumber, final Long offset, final Long length,
final ConnectionCallback callback) {
if(log.isInfoEnabled()) {
log.info(String.format("Submit part %d of %s to queue with offset %d and length %d", partNumber, file, offset, length));
log.info("Submit part {} of {} to queue with offset {} and length {}", partNumber, file, offset, length);
}
return pool.execute(new DefaultRetryCallable<>(session.getHost(), new BackgroundExceptionCallable<B2UploadPartResponse>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public B2LargeUploadPartService(final B2Session session, final B2VersionIdProvid
*/
public List<B2FileInfoResponse> find(final Path file) throws BackgroundException {
if(log.isDebugEnabled()) {
log.debug(String.format("Finding multipart uploads for %s", file));
log.debug("Finding multipart uploads for {}", file);
}
try {
final List<B2FileInfoResponse> uploads = new ArrayList<B2FileInfoResponse>();
Expand All @@ -84,14 +84,14 @@ public List<B2FileInfoResponse> find(final Path file) throws BackgroundException
}
}
if(log.isInfoEnabled()) {
log.info(String.format("Found %d previous multipart uploads for %s", uploads.size(), file));
log.info("Found {} previous multipart uploads for {}", uploads.size(), file);
}
startFileId = chunk.getNextFileId();
}
while(startFileId != null);
if(log.isInfoEnabled()) {
for(B2FileInfoResponse upload : uploads) {
log.info(String.format("Found multipart upload %s for %s", upload, file));
log.info("Found multipart upload {} for {}", upload, file);
}
}
// Uploads are listed in the order they were started, with the oldest one first
Expand All @@ -118,7 +118,7 @@ public int compare(final B2FileInfoResponse o1, final B2FileInfoResponse o2) {
*/
public List<B2UploadPartResponse> list(final String fileid) throws BackgroundException {
if(log.isInfoEnabled()) {
log.info(String.format("List completed parts of file %s", fileid));
log.info("List completed parts of file {}", fileid);
}
// This operation lists the parts that have been uploaded for a specific multipart upload.
try {
Expand Down Expand Up @@ -147,7 +147,7 @@ public List<B2UploadPartResponse> list(final String fileid) throws BackgroundExc
*/
public void delete(final String id) throws BackgroundException {
if(log.isInfoEnabled()) {
log.info(String.format("Delete multipart upload for fileid %s", id));
log.info("Delete multipart upload for fileid {}", id);
}
try {
session.getClient().cancelLargeFileUpload(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ public BaseB2Response upload(final Path file, final Local local,
boolean skip = false;
if(status.isAppend()) {
if(log.isInfoEnabled()) {
log.info(String.format("Determine if part number %d can be skipped", partNumber));
log.info("Determine if part number {} can be skipped", partNumber);
}
for(B2UploadPartResponse c : completed) {
if(c.getPartNumber().equals(partNumber)) {
if(log.isInfoEnabled()) {
log.info(String.format("Skip completed part number %d", partNumber));
log.info("Skip completed part number {}", partNumber);
}
skip = true;
offset += c.getContentLength();
Expand All @@ -177,7 +177,7 @@ public BaseB2Response upload(final Path file, final Local local,
// Submit to queue
parts.add(this.submit(pool, file, local, throttle, listener, status, fileId, partNumber, offset, length, callback));
if(log.isDebugEnabled()) {
log.debug(String.format("Part %s submitted with size %d and offset %d", partNumber, length, offset));
log.debug("Part {} submitted with size {} and offset {}", partNumber, length, offset);
}
remaining -= length;
offset += length;
Expand All @@ -196,7 +196,7 @@ public int compare(final B2UploadPartResponse o1, final B2UploadPartResponse o2)
}
final B2FinishLargeFileResponse response = session.getClient().finishLargeFileUpload(fileId, checksums.toArray(new String[checksums.size()]));
if(log.isInfoEnabled()) {
log.info(String.format("Finished large file upload %s with %d parts", file, completed.size()));
log.info("Finished large file upload {} with {} parts", file, completed.size());
}
fileid.cache(file, response.getFileId());
// Mark parent status as complete
Expand All @@ -220,7 +220,7 @@ private Future<B2UploadPartResponse> submit(final ThreadPool pool, final Path fi
final String fileId, final int partNumber,
final Long offset, final Long length, final ConnectionCallback callback) {
if(log.isInfoEnabled()) {
log.info(String.format("Submit part %d of %s to queue with offset %d and length %d", partNumber, file, offset, length));
log.info("Submit part {} of {} to queue with offset {} and length {}", partNumber, file, offset, length);
}
final BytecountStreamListener counter = new BytecountStreamListener(listener);
return pool.execute(new SegmentRetryCallable<>(session.getHost(), new BackgroundExceptionCallable<B2UploadPartResponse>() {
Expand Down
Loading

0 comments on commit 3c8ad9c

Please sign in to comment.