Skip to content

Commit

Permalink
Clarify nature of performance benefits associated with parameterized …
Browse files Browse the repository at this point in the history
…logging
  • Loading branch information
sambsnyd committed Nov 9, 2023
1 parent f0d296c commit 935f035
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.TypeUtils;

import java.time.Duration;
import java.util.*;

@Value
Expand All @@ -56,12 +55,9 @@ public String getDisplayName() {
@Override
public String getDescription() {
return "Transform logging statements using concatenation for messages and variables into a parameterized format. " +
"For example, `logger.info(\"hi \" + userName)` becomes `logger.info(\"hi {}\", userName)`.";
}

@Override
public Duration getEstimatedEffortPerOccurrence() {
return Duration.ofMinutes(5);
"For example, `logger.info(\"hi \" + userName)` becomes `logger.info(\"hi {}\", userName)`. This can " +
"significantly boost performance for messages that otherwise would be assembled with String concatenation. " +
"Particularly impactful when the log level is not enabled, as no work is done to assemble the message.";
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/META-INF/rewrite/log4j.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.logging.log4j.ParameterizedLogging
displayName: Parameterize Log4j 2.x logging statements
description: Log4j 2.x supports parameterized logging, which can significantly boost logging performance for disabled logging statements.
description: Use Log4j 2.x parameterized logging, which can significantly boost performance for messages that
otherwise would be assembled with String concatenation. Particularly impactful when the log level is not enabled, as
no work is done to assemble the message.
tags:
- logging
- log4j
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/META-INF/rewrite/slf4j.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ recipeList:
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.logging.slf4j.ParameterizedLogging
displayName: Parameterize SLF4J logging statements
description: SLF4J supports parameterized logging, which can significantly boost logging performance for disabled logging statements.
description: Use SLF4J's parameterized logging, which can significantly boost performance for messages that
otherwise would be assembled with String concatenation. Particularly impactful when the log level is not enabled, as
no work is done to assemble the message.
tags:
- logging
- slf4j
Expand Down

0 comments on commit 935f035

Please sign in to comment.