Skip to content

Commit

Permalink
use System.lineSeparator()
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Nov 3, 2023
1 parent 3ad6483 commit 4241154
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* It handles log entries by writing them to the console.
*/
public class ConsoleHandler implements LogEntryHandler {
private static final String NEWLINE = "%n".formatted();
private static final String NEWLINE = System.lineSeparator();
private final PrintStream out;
private final Map<LogLevel, Pair<String, String>> colorMap = new EnumMap<>(LogLevel.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ public interface LogEntry {
Throwable throwable();

default String format(String prefix, String suffix) {
class Constants {
private static final char[] NEW_LINE = String.format("%n").toCharArray();
};

StringBuilder sb = new StringBuilder(100);
sb.append(prefix);
sb.append('[').append(level()).append(']');
Expand All @@ -34,7 +30,7 @@ class Constants {
sb.append(' ');
sb.append(message());
if (throwable() != null) {
sb.append(Constants.NEW_LINE);
sb.append(System.lineSeparator());
appendThrowable(sb);
}
sb.append(suffix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* Represents a log entry with information about the log message, time, level, logger, and optional marker and throwable.
*/
public final class LogEntrySlf4j implements LogEntry {
private static final char[] NEW_LINE = String.format("%n").toCharArray();
private final String loggerName;
private final Instant time;
private final LogLevel level;
Expand Down
2 changes: 1 addition & 1 deletion utility/src/main/java/com/dua3/utility/text/TextUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class TextUtil {
/**
* The current system's end-of-line sequence.
*/
public static final String LINE_END_SYSTEM = String.format("%n");
public static final String LINE_END_SYSTEM = System.lineSeparator();
/**
* UNIX end-of-line sequence.
*/
Expand Down

0 comments on commit 4241154

Please sign in to comment.