Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use parameterized logging #1213

Merged
merged 1 commit into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public Long getValue() {
try {
return metrics.getCumulativeCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing CodaHale metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing CodaHale metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand All @@ -269,7 +269,7 @@ public Long getValue() {
try {
return metrics.getRollingCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing CodaHale metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing CodaHale metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public Long getValue() {
try {
return metrics.getCumulativeCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing CodaHale metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing CodaHale metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand All @@ -526,7 +526,7 @@ public Long getValue() {
try {
return metrics.getRollingCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing CodaHale metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing CodaHale metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ public boolean isRunning() {
private final Object finalizerGuardian = new Object() {
protected void finalize() throws Throwable {
if (!executor.isShutdown()) {
logger.warn(HystrixMetricsPoller.class.getSimpleName() + " was not shutdown. Caught in Finalize Guardian and shutting down.");
logger.warn("{} was not shutdown. Caught in Finalize Guardian and shutting down.", HystrixMetricsPoller.class.getSimpleName());
try {
shutdown();
} catch (Exception e) {
logger.error("Failed to shutdown " + HystrixMetricsPoller.class.getSimpleName(), e);
logger.error("Failed to shutdown {}", HystrixMetricsPoller.class.getSimpleName(), e);
}
}
};
Expand Down Expand Up @@ -193,7 +193,7 @@ private void safelyWriteNumberField(JsonGenerator json, String name, Func0<Long>
try {
json.writeNumberField(name, metricGenerator.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing Hystrix metrics stream, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Hystrix metrics stream, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
json.writeNumberField(name, 0L);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void handleRequest(HttpServletRequest request, final HttpServletResponse
.subscribe(new Subscriber<SampleData>() {
@Override
public void onCompleted() {
logger.error("HystrixSampleSseServlet: (" + getClass().getSimpleName() + ") received unexpected OnCompleted from sample stream");
logger.error("HystrixSampleSseServlet: ({}) received unexpected OnCompleted from sample stream", getClass().getSimpleName());
moreDataWillBeSent.set(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
try {
if (HystrixRequestContext.isCurrentThreadInitialized()) {
HystrixRequestLog log = HystrixRequestLog.getCurrentRequest();
logger.info("Hystrix Executions [" + requestURL.toString() + "] => " + log.getExecutedCommandsAsString());
logger.info("Hystrix Executions [{}] => {}", requestURL.toString(), log.getExecutedCommandsAsString());
}
} catch (Exception e) {
logger.warn("Unable to append HystrixRequestLog", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static void safelyWriteNumberField(JsonGenerator json, String name, Func
try {
json.writeNumberField(name, metricGenerator.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing Hystrix metrics stream, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Hystrix metrics stream, error looking up eventType for : {}. Please check that all Hystrix versions are the same!",name);
json.writeNumberField(name, 0L);
}
}
Expand Down Expand Up @@ -361,4 +361,4 @@ public Long call() {

return jsonString.getBuffer().toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public Long getValue() {
try {
return metrics.getCumulativeCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing Servo metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Servo metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand All @@ -156,7 +156,7 @@ public Long getValue() {
try {
return metrics.getRollingCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing Servo metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Servo metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public Long getValue() {
HystrixEventType eventType = eventThunk.call();
return metrics.getCumulativeCount(HystrixRollingNumberEvent.from(eventType));
} catch (NoSuchFieldError error) {
logger.error("While publishing Servo metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Servo metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand All @@ -211,7 +211,7 @@ public Long getValue() {
HystrixEventType eventType = eventThunk.call();
return metrics.getRollingCount(HystrixRollingNumberEvent.from(eventType));
} catch (NoSuchFieldError error) {
logger.error("While publishing Servo metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Servo metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Long getValue() {
try {
return metrics.getCumulativeCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing Servo metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Servo metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand All @@ -139,7 +139,7 @@ public Long getValue() {
try {
return metrics.getRollingCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing Servo metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Servo metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand Down Expand Up @@ -273,4 +273,4 @@ public Number getValue() {
return monitors;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public Long value() {
try {
return metrics.getCumulativeCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing Yammer metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Yammer metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand All @@ -264,7 +264,7 @@ public Long value() {
try {
return metrics.getRollingCount(eventThunk.call());
} catch (NoSuchFieldError error) {
logger.error("While publishing Yammer metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Yammer metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public Long value() {
HystrixRollingNumberEvent eventType = HystrixRollingNumberEvent.from(eventThunk.call());
return metrics.getCumulativeCount(eventType);
} catch (NoSuchFieldError error) {
logger.error("While publishing Yammer metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Yammer metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand Down Expand Up @@ -450,7 +450,7 @@ public Long value() {
HystrixRollingNumberEvent eventType = HystrixRollingNumberEvent.from(eventThunk.call());
return metrics.getRollingCount(eventType);
} catch (NoSuchFieldError error) {
logger.error("While publishing Yammer metrics, error looking up eventType for : " + name + ". Please check that all Hystrix versions are the same!");
logger.error("While publishing Yammer metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name);
return 0L;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void call(BatchReturnType batchReturnType) {
// now add this to seenKeys, so we can later check what was seen, and what was unseen
seenKeys.add(responseKey);
} else {
logger.warn("Batch Response contained a response key not in request batch : " + responseKey);
logger.warn("Batch Response contained a response key not in request batch : {}", responseKey);
}
} catch (Throwable ex) {
logger.warn("Uncaught error during demultiplexing of BatchResponse", ex);
Expand Down Expand Up @@ -581,4 +581,4 @@ public Setter andCollapserPropertiesDefaults(HystrixCollapserProperties.Setter p
@SuppressWarnings("rawtypes")
private static ConcurrentHashMap<Class<? extends HystrixObservableCollapser>, String> defaultNameCache = new ConcurrentHashMap<Class<? extends HystrixObservableCollapser>, String>();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public RequestCollapser<BatchReturnType, ResponseType, RequestArgumentType> getR
} else if (Scopes.GLOBAL == Scopes.valueOf(getScope().name())) {
return getCollapserForGlobalScope(commandCollapser);
} else {
logger.warn("Invalid Scope: " + getScope() + " Defaulting to REQUEST scope.");
logger.warn("Invalid Scope: {} Defaulting to REQUEST scope.", getScope());
return getCollapserForUserRequest(commandCollapser);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ protected void checkAndFlip() {
}

if (this.isValueAcceptable()) {
logger.debug("Flipping property: " + getName() + " to use it's current value:" + getValue());
logger.debug("Flipping property: {} to use it's current value: {}", getName(), getValue());
pReference.set(this);
} else {
logger.debug("Flipping property: " + getName() + " to use NEXT property: " + next);
logger.debug("Flipping property: {} to use NEXT property: {}", getName(), next);
pReference.set(next);
}

Expand Down Expand Up @@ -155,7 +155,7 @@ public StringProperty(DynamicStringProperty sProperty, StringProperty next) {
sProp.addCallback(new Runnable() {
@Override
public void run() {
logger.debug("Property changed: '" + getName() + " = " + getValue() + "'");
logger.debug("Property changed: '{} = {}'", getName(), getValue());
checkAndFlip();
}
});
Expand Down Expand Up @@ -209,7 +209,7 @@ public IntegerProperty(DynamicIntegerProperty sProperty, IntegerProperty next) {
sProp.addCallback(new Runnable() {
@Override
public void run() {
logger.debug("Property changed: '" + getName() + " = " + getValue() + "'");
logger.debug("Property changed: '{} = {}'", getName(), getValue());
checkAndFlip();
}
});
Expand Down Expand Up @@ -263,7 +263,7 @@ public BooleanProperty(DynamicBooleanProperty sProperty, BooleanProperty next) {
sProp.addCallback(new Runnable() {
@Override
public void run() {
logger.debug("Property changed: '" + getName() + " = " + getValue() + "'");
logger.debug("Property changed: '{} = {}'", getName(), getValue());
checkAndFlip();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ protected void checkAndFlip() {
}

if (this.isValueAcceptable()) {
logger.debug("Flipping property: " + getName() + " to use it's current value:" + getValue());
logger.debug("Flipping property: {} to use it's current value: {}", getName(), getValue());
pReference.set(this);
} else {
logger.debug("Flipping property: " + getName() + " to use NEXT property: " + next);
logger.debug("Flipping property: {} to use NEXT property: {}", getName(), next);
pReference.set(next);
}

Expand Down Expand Up @@ -233,7 +233,7 @@ public ChainProperty(HystrixDynamicProperty<T> sProperty, ChainProperty<T> next)
sProp.addCallback(new Runnable() {
@Override
public void run() {
logger.debug("Property changed: '" + getName() + " = " + getValue() + "'");
logger.debug("Property changed: '{} = {}'", getName(), getValue());
checkAndFlip();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
}
}
String proxyUrl = url.toString();
logger.info("\n\nProxy opening connection to: " + proxyUrl + "\n\n");
logger.info("\n\nProxy opening connection to: {}\n\n", proxyUrl);
try {
httpget = new HttpGet(proxyUrl);
if (authorization != null) {
Expand Down