Skip to content

Commit 1b861da

Browse files
authored
Cleanup: Standardize logger message formatting in ApiServer.java (#11188)
1 parent 1ef6365 commit 1b861da

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

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

462462
final Long snapshotLimit = ConcurrentSnapshotsThresholdPerHost.value();
463463
if (snapshotLimit == null || snapshotLimit <= 0) {
464-
logger.debug("Global concurrent snapshot config parameter " + ConcurrentSnapshotsThresholdPerHost.value() + " is less or equal 0; defaulting to unlimited");
464+
logger.debug("Global concurrent snapshot config parameter {} is less or equal 0; defaulting to unlimited", ConcurrentSnapshotsThresholdPerHost.value());
465465
} else {
466466
dispatcher.setCreateSnapshotQueueSizeLimit(snapshotLimit);
467467
}
468468

469469
final Long migrationLimit = VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value();
470470
if (migrationLimit == null || migrationLimit <= 0) {
471-
logger.debug("Global concurrent migration config parameter " + VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value() + " is less or equal 0; defaulting to unlimited");
471+
logger.debug("Global concurrent migration config parameter {} is less or equal 0; defaulting to unlimited", VolumeApiService.ConcurrentMigrationsThresholdPerDatastore.value());
472472
} else {
473473
dispatcher.setMigrateQueueSizeLimit(migrationLimit);
474474
}
@@ -647,7 +647,7 @@ public String handleRequest(final Map params, final String responseType, final S
647647
logValue = (value == null) ? "'null'" : value[0];
648648
}
649649

650-
logger.trace(" key: " + keyStr + ", value: " + logValue);
650+
logger.trace(" key: {}, value: {}", keyStr, logValue);
651651
}
652652
}
653653
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "Invalid request, no command sent");
@@ -707,7 +707,7 @@ public String handleRequest(final Map params, final String responseType, final S
707707
buf.append(obj.getUuid());
708708
buf.append(" ");
709709
}
710-
logger.info("PermissionDenied: " + ex.getMessage() + " on objs: [" + buf + "]");
710+
logger.info("PermissionDenied: {} on objs: [{}]", ex.getMessage(), buf);
711711
} else {
712712
logger.info("PermissionDenied: {}", ex.getMessage());
713713
}
@@ -1035,7 +1035,7 @@ public boolean verifyRequest(final Map<String, Object[]> requestParameters, fina
10351035

10361036
// if api/secret key are passed to the parameters
10371037
if ((signature == null) || (apiKey == null)) {
1038-
logger.debug("Expired session, missing signature, or missing apiKey -- ignoring request. Signature: " + signature + ", apiKey: " + apiKey);
1038+
logger.warn("Expired session, missing signature, or missing apiKey -- ignoring request. Signature: {}, apiKey: {}", signature, apiKey);
10391039
return false; // no signature, bad request
10401040
}
10411041

@@ -1258,7 +1258,7 @@ public ResponseObject loginUser(final HttpSession session, final String username
12581258
float offsetInHrs = 0f;
12591259
if (timezone != null) {
12601260
final TimeZone t = TimeZone.getTimeZone(timezone);
1261-
logger.info("Current user logged in under " + timezone + " timezone");
1261+
logger.info("Current user logged in under {} timezone", timezone);
12621262

12631263
final java.util.Date date = new java.util.Date();
12641264
final long longDate = date.getTime();
@@ -1410,9 +1410,9 @@ private void checkCommandAvailable(final User user, final String commandName, fi
14101410
final Boolean apiSourceCidrChecksEnabled = ApiServiceConfiguration.ApiSourceCidrChecksEnabled.value();
14111411

14121412
if (apiSourceCidrChecksEnabled) {
1413-
logger.debug("CIDRs from which account '" + account.toString() + "' is allowed to perform API calls: " + accessAllowedCidrs);
1413+
logger.debug("CIDRs from which account '{}' is allowed to perform API calls: {}", account.toString(), accessAllowedCidrs);
14141414
if (!NetUtils.isIpInCidrList(remoteAddress, accessAllowedCidrs.split(","))) {
1415-
logger.warn("Request by account '" + account.toString() + "' was denied since " + remoteAddress + " does not match " + accessAllowedCidrs);
1415+
logger.warn("Request by account '{}' was denied since {} does not match {}", account.toString(), remoteAddress, accessAllowedCidrs);
14161416
throw new OriginDeniedException("Calls from disallowed origin", account, remoteAddress);
14171417
}
14181418
}

0 commit comments

Comments
 (0)