Skip to content

Commit cb74603

Browse files
committed
Re-add message
1 parent e2270d8 commit cb74603

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

internal/entryhuman/entry.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,26 @@ func render(w io.Writer, st lipgloss.Style, s string) string {
4949
return s
5050
}
5151

52+
func reset(w io.Writer, termW io.Writer) {
53+
if shouldColor(termW) {
54+
fmt.Fprintf(w, termenv.CSI+termenv.ResetSeq+"m")
55+
}
56+
}
57+
5258
// Fmt returns a human readable format for ent.
5359
//
5460
// We never return with a trailing newline because Go's testing framework adds one
5561
// automatically and if we include one, then we'll get two newlines.
5662
// We also do not indent the fields as go's test does that automatically
5763
// for extra lines in a log so if we did it here, the fields would be indented
5864
// twice in test logs. So the Stderr logger indents all the fields itself.
59-
func Fmt(buf io.StringWriter, termW io.Writer, ent slog.SinkEntry,
65+
func Fmt(
66+
buf interface {
67+
io.StringWriter
68+
io.Writer
69+
}, termW io.Writer, ent slog.SinkEntry,
6070
) {
71+
reset(buf, termW)
6172
ts := ent.Time.Format(TimeFormat)
6273
buf.WriteString(ts + " ")
6374

@@ -83,9 +94,8 @@ func Fmt(buf io.StringWriter, termW io.Writer, ent slog.SinkEntry,
8394
multilineVal = msg
8495
msg = "..."
8596
msg = quote(msg)
86-
buf.WriteString(msg)
87-
8897
}
98+
buf.WriteString(msg)
8999

90100
if ent.SpanContext != (trace.SpanContext{}) {
91101
ent.Fields = append(slog.M(

internal/entryhuman/entry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func BenchmarkFmt(b *testing.B) {
145145
b.ResetTimer()
146146
b.ReportAllocs()
147147
for i := 0; i < b.N; i++ {
148-
entryhuman.Fmt(io.Discard.(io.StringWriter), w, se)
148+
entryhuman.Fmt(bytes.NewBuffer(nil), w, se)
149149
}
150150
})
151151
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
0001-01-01 00:00:00.000 [INFO] ...
1+
0001-01-01 00:00:00.000 [INFO] msg ...
22
field= line1
33
line2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2000-02-05 04:04:04.000 [DEBU]
1+
2000-02-05 04:04:04.000 [DEBU] wowowow izi

0 commit comments

Comments
 (0)