-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating log levels analyzer to allow usage of split (#160)
* Updating log levels analyzer to allow usage of split without leaving a comment * Leaving a comment to use substring when detecting that neither split or substring have been used
- Loading branch information
1 parent
b09c4e0
commit f5ba7ba
Showing
15 changed files
with
108 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
src/test/resources/scenarios/log-levels/NotUsingExpectedMethodsOnLogLevel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package scenarios.loglevels; | ||
|
||
public class LogLevels { | ||
|
||
public static String message(String logLine) { | ||
return logLine.substring(logLine.indexOf(":") + 1).trim(); | ||
} | ||
|
||
public static String logLevel(String logLine) { | ||
int closingBracketIndex = logLine.indexOf("]"); | ||
if (closingBracketIndex == -1) { | ||
return logLine.toLowerCase(); | ||
} | ||
|
||
StringBuilder levelBuilder = new StringBuilder(); | ||
for (int i = 0; i <= closingBracketIndex; i++) { | ||
levelBuilder.append(logLine.charAt(i)); | ||
} | ||
|
||
return levelBuilder.toString().replace("[", "").replace("]", "").toLowerCase(); | ||
} | ||
|
||
|
||
public static String reformat(String logLine) { | ||
return message(logLine) + " (" + logLevel(logLine) + ")"; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/resources/scenarios/log-levels/NotUsingExpectedMethodsOnLogLevelAndMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package scenarios.loglevels; | ||
|
||
public class LogLevels { | ||
|
||
public static String message(String logLine) { | ||
int colonIndex = logLine.indexOf("]: "); | ||
if (colonIndex == -1) { | ||
return logLine; | ||
} | ||
|
||
StringBuilder messageBuilder = new StringBuilder(); | ||
for (int i = colonIndex + 3; i < logLine.length(); i++) { | ||
messageBuilder.append(logLine.charAt(i)); | ||
} | ||
|
||
return messageBuilder.toString().trim(); | ||
} | ||
|
||
public static String logLevel(String logLine) { | ||
int closingBracketIndex = logLine.indexOf("]"); | ||
if (closingBracketIndex == -1) { | ||
return logLine.toLowerCase(); | ||
} | ||
|
||
StringBuilder levelBuilder = new StringBuilder(); | ||
for (int i = 0; i <= closingBracketIndex; i++) { | ||
levelBuilder.append(logLine.charAt(i)); | ||
} | ||
|
||
return levelBuilder.toString().replace("[", "").replace("]", "").toLowerCase(); | ||
} | ||
|
||
|
||
public static String reformat(String logLine) { | ||
return message(logLine) + " (" + logLevel(logLine) + ")"; | ||
} | ||
} |
13 changes: 12 additions & 1 deletion
13
...og-levels/NotUsingSubstringOnMessage.java → ...els/NotUsingExpectedMethodsOnMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/test/resources/scenarios/log-levels/NotUsingSubstringOnBothMethods.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/test/resources/scenarios/log-levels/NotUsingSubstringOnLogLevel.java
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
tests/log-levels/no-expected_methods-used/src/main/java/LogLevels.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class LogLevels { | ||
public static String message(String logLine) { | ||
int colonIndex = logLine.indexOf("]: "); | ||
if (colonIndex == -1) { | ||
return logLine; | ||
} | ||
|
||
StringBuilder messageBuilder = new StringBuilder(); | ||
for (int i = colonIndex + 3; i < logLine.length(); i++) { | ||
messageBuilder.append(logLine.charAt(i)); | ||
} | ||
|
||
return messageBuilder.toString().trim(); | ||
} | ||
|
||
public static String logLevel(String logLine) { | ||
return logLine.substring(1, logLine.indexOf("]")).toLowerCase(); | ||
} | ||
|
||
public static String reformat(String logLine) { | ||
return message(logLine) + " (" + logLevel(logLine) + ")"; | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
tests/log-levels/no-substring-used/src/main/java/LogLevels.java
This file was deleted.
Oops, something went wrong.