Skip to content

Commit 3f62a6f

Browse files
authored
Merge pull request #4155 from apostasie/tigron-2025-04-shorten-max-log-length
[Tigron]: shorten max lines in logs to 50 and add message
2 parents 5c06c7d + c70adab commit 3f62a6f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

mod/tigron/internal/formatter/formatter.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
const (
2727
maxLineLength = 110
28-
maxLines = 100
28+
maxLines = 50
2929
kMaxLength = 7
3030
spacer = " "
3131
)
@@ -107,11 +107,20 @@ func chunk(s string, maxLength, maxLines int) []string {
107107
chunks = append(chunks, segment)
108108
}
109109

110+
// If really long, preserve the starting first quarter, the trailing three quarters, and inform.
110111
if len(chunks) > maxLines {
111-
abbreviator := "..."
112+
abbreviator := fmt.Sprintf("... %d lines are being ignored...", len(chunks)-maxLines)
112113
chunks = append(
113-
append(chunks[0:maxLines/2], abbreviator+strings.Repeat(spacer, maxLength-len(abbreviator))),
114-
chunks[len(chunks)-maxLines/2:]...)
114+
append(chunks[0:maxLines/4], abbreviator+strings.Repeat(spacer, maxLength-len(abbreviator))),
115+
chunks[len(chunks)-maxLines*3/4:]...,
116+
)
117+
chunks = append(
118+
[]string{
119+
fmt.Sprintf("Actual content is %d lines long and has been abbreviated to %d\n", len(chunks), maxLines),
120+
strings.Repeat(spacer, maxLength),
121+
},
122+
chunks...,
123+
)
115124
} else if len(chunks) == 0 {
116125
chunks = []string{strings.Repeat(spacer, maxLength)}
117126
}

0 commit comments

Comments
 (0)