Skip to content

Commit

Permalink
fix(log-core):修复 TableFormat 错误
Browse files Browse the repository at this point in the history
  • Loading branch information
SakurajimaMaii committed Oct 15, 2024
1 parent d6a41d2 commit 08736a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,29 @@ class TableFormat(
var count = 0
logFormat(logInfo, maxSingleLogLength * 4) { body, content ->
// FIX: DEAL LINE SEPARATOR THAT EXIST WITHIN THE LOG CONTENT
content.split("\n", System.lineSeparator()).forEach { pattern ->
val patterns = content.split("\n", System.lineSeparator())
patterns.forEach { pattern ->
var bytes = pattern.toByteArray()
if (maxSingleLogLength * 4 < bytes.size) {
do {
val subStr = bytes.cutStr(maxSingleLogLength)
body.appendLine(LogDivider.getInfo(String.format("%s", subStr)))
bytes = bytes.copyOfRange(subStr.toByteArray().size, bytes.size)
count++
bytes = bytes.copyOfRange(subStr.toByteArray().size, bytes.size)
// Finish print
if (count == maxPrintTimes) {
if (count >= maxPrintTimes) {
ellipsis?.also { body.appendLine(LogDivider.getInfo(it)) }
return@logFormat
}
} while (maxSingleLogLength * 4 < bytes.size)
} else {
body.appendLine(LogDivider.getInfo(String.format("%s", String(bytes))))
count++
}

if (count <= maxPrintTimes) {
body.appendLine(LogDivider.getInfo(String.format("%s", String(bytes))))
if (count >= maxPrintTimes) {
ellipsis?.also { body.appendLine(LogDivider.getInfo(it)) }
return@logFormat
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ val logFactory: LogFactory = getLogFactory {
}
install(LogPrinter) {
levelSet = allLogLevel
logger = SimpleLogger(TableFormat(1000, 20, ellipsis = "******"))
logger = SimpleLogger(TableFormat(1000, 5, ellipsis = "......"))
//logger = SimpleLogger(LineFormat)
}
install(LogJson) {
Expand Down

0 comments on commit 08736a1

Please sign in to comment.