Permalink
Browse files

Utilize parameterized logging

As suggested in the SLF4J FAQ: https://www.slf4j.org/faq.html#logging_performance
parameterized logging can improve the efficiency of logger calls when
logging at the specified level is disabled.

These changes were suggested by SLF4J Helper for NetBeans IDE:
http://plugins.netbeans.org/plugin/72557/
  • Loading branch information...
Daniel Trebbien
Daniel Trebbien committed Jul 22, 2017
1 parent 88657b8 commit 7f0cbf0aeca0eaf889af534ef97b4af4640beba1
@@ -143,10 +143,10 @@ public T load(String key) throws EVCacheException {
} catch (DataNotFoundException e) {
throw e;
} catch (EVCacheException e) {
log.error("EVCacheException while loading key -> "+ key, e);
log.error("EVCacheException while loading key -> {}", key, e);
throw e;
} catch (Exception e) {
log.error("EVCacheException while loading key -> "+ key, e);
log.error("Exception while loading key -> {}", key, e);
throw new EVCacheException("key : " + key + " could not be loaded", e);
}
}
@@ -164,7 +164,7 @@ public T call() {
}
return t;
} catch (EVCacheException e) {
log.error("EVCacheException while reloading key -> "+ key, e);
log.error("EVCacheException while reloading key -> {}", key, e);
EVCacheMetricsFactory.increment(appName, null, null, "EVCacheInMemoryCache" + "-" + appName + "-Reload-Fail");
return prev;
}
@@ -199,7 +199,7 @@ private void setupMonitoring(final String appName) {
@Override
public Number getValue() {
if (getCache() == null) return Long.valueOf(0);
log.debug("Current size is : " + getCache().size());
log.debug("Current size is : {}", getCache().size());
return Long.valueOf(getCache().size());
}
@@ -75,8 +75,9 @@ public DiscoveryNodeListProvider(ApplicationInfoManager applicationInfoManager,
/* Only AWS instances are usable; bypass all others */
if (DataCenterInfo.Name.Amazon != dcInfo.getName() || !(dcInfo instanceof AmazonInfo)) {
log.error("This is not a AWSDataCenter. You will not be able to use Discovery Nodelist Provider. Cannot proceed. DataCenterInfo : "
+ dcInfo + "; appName - " + _appName + ". Please use SimpleNodeList provider and specify the server groups manually.");
log.error("This is not an AWSDataCenter. You will not be able to use Discovery Nodelist Provider. Cannot proceed. " +
"DataCenterInfo : {}; appName - {}. Please use SimpleNodeList provider and specify the server groups manually.",
dcInfo, _appName);
continue;
}
@@ -199,7 +199,7 @@ public EVCacheClient getEVCacheClientForRead() {
}
return selectClient(clients);
} catch (Throwable t) {
log.error("Exception trying to get an readable EVCache Instances for zone " + _zone, t);
log.error("Exception trying to get an readable EVCache Instances for zone {}", _zone, t);
return null;
}
}
@@ -230,7 +230,7 @@ public EVCacheClient getEVCacheClientForReadExclude(ServerGroup rsetUsed) {
final List<EVCacheClient> clients = memcachedReadInstancesByServerGroup.get(fallbackServerGroup);
return selectClient(clients);
} catch (Throwable t) {
log.error("Exception trying to get an readable EVCache Instances for zone " + rsetUsed, t);
log.error("Exception trying to get an readable EVCache Instances for zone {}", rsetUsed, t);
return null;
}
}
@@ -250,7 +250,7 @@ public EVCacheClient getEVCacheClient(ServerGroup serverGroup) {
}
return selectClient(clients);
} catch (Throwable t) {
log.error("Exception trying to get an readable EVCache Instances for ServerGroup " + serverGroup, t);
log.error("Exception trying to get an readable EVCache Instances for ServerGroup {}", serverGroup, t);
return null;
}
}
@@ -291,7 +291,7 @@ public EVCacheClient getEVCacheClient(ServerGroup serverGroup) {
}
}
} catch (Throwable t) {
log.error("Exception trying to get an readable EVCache Instances for zone " + serverGroupToExclude, t);
log.error("Exception trying to get an readable EVCache Instances for zone {}", serverGroupToExclude, t);
}
return Collections.<EVCacheClient> emptyList();
}
@@ -779,8 +779,8 @@ private synchronized void refresh(boolean force) throws IOException {
lastReconcileTime = System.currentTimeMillis();
} catch (Exception e) {
EVCacheMetricsFactory.increment("EVCacheClientPool-" + _appName + "-" + serverGroup.getName() + "EVCacheClient-INIT_ERROR");
log.error("Unable to create EVCacheClient for app - " + _appName + " and Server Group - "
+ serverGroup.getName(), e);
log.error("Unable to create EVCacheClient for app - {} and Server Group - {}",
_appName, serverGroup.getName(), e);
}
}
if (newClients.size() > 0) setupNewClientsByServerGroup(serverGroup, newClients);
@@ -75,7 +75,7 @@ public SimpleNodeListProvider(String propertyName) {
}
currentNodeList = nodeListString;
log.debug("List by Servergroup" + instancesSpecific);
log.debug("List by Servergroup {}", instancesSpecific);
return instancesSpecific;
}
@@ -125,7 +125,7 @@ public void gotData(String k, int flags, byte[] data) {
if(getDataSize == null) getDataSize = EVCacheMetricsFactory.getDistributionSummary(appName + "-GetOperation-DataSize", appName, serverGroup.getName());
if (getDataSize != null) getDataSize.record(data.length);
}
if (!key.equals(k)) log.warn("Wrong key returned. Key - " + key + "; Returned Key " + k);
if (!key.equals(k)) log.warn("Wrong key returned. Key - {}; Returned Key {}", key, k);
if (tc == null) {
if (tcService == null) {
log.error("tcService is null, will not be able to decode");
@@ -242,7 +242,7 @@ public void complete() {
}
public void gotData(String k, int flags, long cas, byte[] data) {
if (!key.equals(k)) log.warn("Wrong key returned. Key - " + key + "; Returned Key " + k);
if (!key.equals(k)) log.warn("Wrong key returned. Key - {}; Returned Key {}", key, k);
if (data != null) {
if(getAndTouchDataSize == null) getAndTouchDataSize = EVCacheMetricsFactory.getDistributionSummary(appName + "-GATOperation-DataSize", appName, serverGroup.getName());
if (getAndTouchDataSize != null) getAndTouchDataSize.record(data.length);

0 comments on commit 7f0cbf0

Please sign in to comment.