Skip to content

there is no need to use substring in the result method in this code, kindly review #176

Open
@johanjaguardev

Description

@johanjaguardev

public class LogLevels {

public static String message(String logLine) {
    int startMessageIndex = logLine.indexOf("]:") + 2;
    String result = logLine.substring(startMessageIndex, logLine.length());
    return result.trim();
}
public static String logLevel(String logLine) {
    int startLevelIndex = logLine.indexOf("[") + 1;
    int endLevelIndex = logLine.indexOf("]");
    return logLine.substring(startLevelIndex, endLevelIndex).toLowerCase();
}
public static String reformat(String logLine) {
    return LogLevels.message(logLine) + " (" + LogLevels.logLevel(logLine) + ")";
}
public static void result() {
    String logLine = "[ERROR]: Invalid operation";
    String formattedString =  LogLevels.reformat(logLine);
}

}

and the suggestion is:
Consider using the substring method in result to solve this exercise. but for this exercise the substring method is implemented in the other methods, kindly review.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions