Skip to content

Commit a6b0bec

Browse files
he1l0worlddhslove
authored andcommitted
Cleanup: Standardize logger message formatting in ApiServer.java (apache#11188)
1 parent e45947a commit a6b0bec

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

server/src/main/java/com/cloud/api/ApiServer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,14 @@ public boolean start() {
496496

497497
final Long snapshotLimit = ConcurrentSnapshotsThresholdPerHost.value();
498498
if (snapshotLimit == null || snapshotLimit <= 0) {
499-
logger.debug("Global concurrent snapshot config parameter " + ConcurrentSnapshotsThresholdPerHost.value() + " is less or equal 0; defaulting to unlimited");
499+
logger.debug("Global concurrent snapshot config parameter {} is less or equal 0; defaulting to unlimited", ConcurrentSnapshotsThresholdPerHost.value());
500500
} else {
501501
dispatcher.setCreateSnapshotQueueSizeLimit(snapshotLimit);
502502
}
503503

504504
final Long migrationLimit = VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value();
505505
if (migrationLimit == null || migrationLimit <= 0) {
506-
logger.debug("Global concurrent migration config parameter " + VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value() + " is less or equal 0; defaulting to unlimited");
506+
logger.debug("Global concurrent migration config parameter {} is less or equal 0; defaulting to unlimited", VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value());
507507
} else {
508508
dispatcher.setMigrateQueueSizeLimit(migrationLimit);
509509
}
@@ -682,7 +682,7 @@ public String handleRequest(final Map params, final String responseType, final S
682682
logValue = (value == null) ? "'null'" : value[0];
683683
}
684684

685-
logger.trace(" key: " + keyStr + ", value: " + logValue);
685+
logger.trace(" key: {}, value: {}", keyStr, logValue);
686686
}
687687
}
688688
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "Invalid request, no command sent");
@@ -742,7 +742,7 @@ public String handleRequest(final Map params, final String responseType, final S
742742
buf.append(obj.getUuid());
743743
buf.append(" ");
744744
}
745-
logger.info("PermissionDenied: " + ex.getMessage() + " on objs: [" + buf + "]");
745+
logger.info("PermissionDenied: {} on objs: [{}]", ex.getMessage(), buf);
746746
} else {
747747
logger.info("PermissionDenied: {}", ex.getMessage());
748748
}
@@ -1070,7 +1070,7 @@ public boolean verifyRequest(final Map<String, Object[]> requestParameters, fina
10701070

10711071
// if api/secret key are passed to the parameters
10721072
if ((signature == null) || (apiKey == null)) {
1073-
logger.debug("Expired session, missing signature, or missing apiKey -- ignoring request. Signature: " + signature + ", apiKey: " + apiKey);
1073+
logger.warn("Expired session, missing signature, or missing apiKey -- ignoring request. Signature: {}, apiKey: {}", signature, apiKey);
10741074
return false; // no signature, bad request
10751075
}
10761076

@@ -1329,7 +1329,7 @@ public ResponseObject loginUser(final HttpSession session, final String username
13291329
float offsetInHrs = 0f;
13301330
if (timezone != null) {
13311331
final TimeZone t = TimeZone.getTimeZone(timezone);
1332-
logger.info("Current user logged in under " + timezone + " timezone");
1332+
logger.info("Current user logged in under {} timezone", timezone);
13331333

13341334
final java.util.Date date = new java.util.Date();
13351335
final long longDate = date.getTime();
@@ -1509,9 +1509,9 @@ private void checkCommandAvailable(final User user, final String commandName, fi
15091509
final Boolean apiSourceCidrChecksEnabled = ApiServiceConfiguration.ApiSourceCidrChecksEnabled.value();
15101510

15111511
if (apiSourceCidrChecksEnabled) {
1512-
logger.debug("CIDRs from which account '" + account.toString() + "' is allowed to perform API calls: " + accessAllowedCidrs);
1512+
logger.debug("CIDRs from which account '{}' is allowed to perform API calls: {}", account.toString(), accessAllowedCidrs);
15131513
if (!NetUtils.isIpInCidrList(remoteAddress, accessAllowedCidrs.split(","))) {
1514-
logger.warn("Request by account '" + account.toString() + "' was denied since " + remoteAddress + " does not match " + accessAllowedCidrs);
1514+
logger.warn("Request by account '{}' was denied since {} does not match {}", account.toString(), remoteAddress, accessAllowedCidrs);
15151515
throw new OriginDeniedException("Calls from disallowed origin", account, remoteAddress);
15161516
}
15171517
}

0 commit comments

Comments
 (0)