-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathUsingExtraHelperMethod.java
More file actions
25 lines (20 loc) · 845 Bytes
/
UsingExtraHelperMethod.java
File metadata and controls
25 lines (20 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package scenarios.loglevels;
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);
}
}