Skip to content

Commit 90f384e

Browse files
he1l0worldowsferraro
authored andcommitted
Cleanup: Standardize logger message formatting in ApiServer.java (apache#11188)
1 parent e9fdd44 commit 90f384e

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
@@ -462,14 +462,14 @@ public boolean start() {
462462

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

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

651-
logger.trace(" key: " + keyStr + ", value: " + logValue);
651+
logger.trace(" key: {}, value: {}", keyStr, logValue);
652652
}
653653
}
654654
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "Invalid request, no command sent");
@@ -708,7 +708,7 @@ public String handleRequest(final Map params, final String responseType, final S
708708
buf.append(obj.getUuid());
709709
buf.append(" ");
710710
}
711-
logger.info("PermissionDenied: " + ex.getMessage() + " on objs: [" + buf + "]");
711+
logger.info("PermissionDenied: {} on objs: [{}]", ex.getMessage(), buf);
712712
} else {
713713
logger.info("PermissionDenied: {}", ex.getMessage());
714714
}
@@ -1036,7 +1036,7 @@ public boolean verifyRequest(final Map<String, Object[]> requestParameters, fina
10361036

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

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

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

14321432
if (apiSourceCidrChecksEnabled) {
1433-
logger.debug("CIDRs from which account '" + account.toString() + "' is allowed to perform API calls: " + accessAllowedCidrs);
1433+
logger.debug("CIDRs from which account '{}' is allowed to perform API calls: {}", account.toString(), accessAllowedCidrs);
14341434
if (!NetUtils.isIpInCidrList(remoteAddress, accessAllowedCidrs.split(","))) {
1435-
logger.warn("Request by account '" + account.toString() + "' was denied since " + remoteAddress + " does not match " + accessAllowedCidrs);
1435+
logger.warn("Request by account '{}' was denied since {} does not match {}", account.toString(), remoteAddress, accessAllowedCidrs);
14361436
throw new OriginDeniedException("Calls from disallowed origin", account, remoteAddress);
14371437
}
14381438
}

0 commit comments

Comments
 (0)