[dev_arch_opt_3.0] 优化日志打印逻辑,去掉对象锁

This commit is contained in:
renwj
2023-03-13 17:29:59 +08:00
parent fe9e24e2e8
commit 4fb80ac739

View File

@@ -132,32 +132,9 @@ final class LoggerPrinter implements Printer {
}
}
private synchronized void log( String tag, LogLevel logLevel, String msg, Object... args) {
private void log( String tag, LogLevel logLevel, String msg, Object... args) {
String message = this.createMessage(msg, args);
int methodCount = this.getMethodCount();
this.logTopBorder(logLevel, tag);
this.logHeaderContent(logLevel, tag, methodCount);
byte[] bytes = message.getBytes();
int length = bytes.length;
if (length <= 4000) {
if (methodCount > 0) {
this.logDivider(logLevel, tag);
}
this.logContent(logLevel, tag, message);
this.logBottomBorder(logLevel, tag);
} else {
if (methodCount > 0) {
this.logDivider(logLevel, tag);
}
for (int i = 0; i < length; i += 4000) {
int count = Math.min(length - i, 4000);
this.logContent(logLevel, tag, new String(bytes, i, count));
}
this.logBottomBorder(logLevel, tag);
}
logContent(logLevel, tag, message);
}
private void logTopBorder(LogLevel logLevel, String tag) {
@@ -198,11 +175,13 @@ final class LoggerPrinter implements Printer {
}
private void logContent( LogLevel logLevel, String tag, String chunk) {
String[] lines = chunk.split( System.getProperty("line.separator"));
for ( String line : lines) {
this.logChunk(logLevel, tag, "" + line);
}
// String[] lines = chunk.split( System.getProperty("line.separator"));
//
// for ( String line : lines) {
// this.logChunk(logLevel, tag, "║ " + line);
// }
//
logChunk(logLevel, tag, chunk);
}
private void logChunk( LogLevel logLevel, String tag, String chunk) {