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

CAMEL-12004 Add isDebugEnabled() guard for debug level logs #2093

Closed
wants to merge 1 commit into from

Conversation

mehranhassani
Copy link
Contributor

I added the debug level guards to the one that I found with my script in the latest revision of source code.

@PascalSchumacher
Copy link
Contributor

Thanks for the pull request.

Imho it would be better to convert the statements to parametrized log messages (where possible). That also saves the cost of the string concatenation (I do not see any potentially costly parameter creation) and does not add the complexity of an additional if statement to the code.

@mehranhassani
Copy link
Contributor Author

I think the best way to deal with this problem is to use slf4j. But I don't know how costly the migration will be. I can look into the changes and try to parameterize them if its possible if this is the best solution in your opinion.

@@ -154,7 +154,7 @@ protected void processInTransaction(final Exchange exchange) throws Exception {
if (log.isDebugEnabled()) {
// log exception if there was a cause exception so we have the stack trace
Exception cause = exchange.getException();
if (cause != null) {
if (cause != null && log.isDebugEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log debug enable is already checked above

@@ -94,8 +94,9 @@ protected Object evaluateExpression(String expressionText, String expectedValue)
} else {
value = expression.evaluate(exchange, Object.class);
}

log.debug("Evaluated expression: {} on exchange: {} result: {}", expression, exchange, value);
if (log.isDebugEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed when using {}

@@ -131,7 +131,9 @@ protected AbstractMessageListenerContainer createListenerContainer() throws Exce
answer = new SharedQueueMessageListenerContainer(endpoint, fixedMessageSelector);
// must use cache level consumer for fixed message selector
answer.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
log.debug("Using shared queue: " + endpoint.getReplyTo() + " with fixed message selector [" + fixedMessageSelector + "] as reply listener: " + answer);
if (log.isDebugEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use {} style here

@@ -85,8 +85,9 @@ protected void assertExpression(String expressionText, String expectedValue, Str
} else {
value = expression.evaluate(exchange, Object.class);
}

log.debug("Evaluated expression: " + expression + " on exchange: " + exchange + " result: " + value);
if (log.isDebugEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest is just unit tests and tooling so its not as important as runtime camel-core etc. However the changes are fine to do, but maybe favor using {} style

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, you do not recommend increasing complexity with the if statement. right?

@davsclaus davsclaus closed this in 22ac8c0 Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants