Skip to content

Commit 0de0e7c

Browse files
authoredMar 29, 2023
add newlines to GinkgoLogr (#1170) (#1171)
1 parent 9b5078f commit 0de0e7c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
 

‎internal/writer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,6 @@ func (w *Writer) Println(a ...interface{}) {
135135

136136
func GinkgoLogrFunc(writer *Writer) logr.Logger {
137137
return funcr.New(func(prefix, args string) {
138-
writer.Printf("%s", args)
138+
writer.Printf("%s\n", args)
139139
}, funcr.Options{})
140140
}

‎internal/writer_test.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,20 @@ var _ = Describe("Writer", func() {
129129
It("can print Info logs", func() {
130130
log := internal.GinkgoLogrFunc(writer)
131131
log.Info("message", "key", 5)
132-
Ω(string(out.Contents())).Should(Equal(" \"level\"=0 \"msg\"=\"message\" \"key\"=5"))
132+
Ω(string(out.Contents())).Should(Equal(" \"level\"=0 \"msg\"=\"message\" \"key\"=5\n"))
133133
})
134134

135135
It("can print Error logs", func() {
136136
log := internal.GinkgoLogrFunc(writer)
137137
log.Error(errors.New("cake"), "planned failure", "key", "banana")
138-
Ω(string(out.Contents())).Should(Equal(" \"msg\"=\"planned failure\" \"error\"=\"cake\" \"key\"=\"banana\""))
138+
Ω(string(out.Contents())).Should(Equal(" \"msg\"=\"planned failure\" \"error\"=\"cake\" \"key\"=\"banana\"\n"))
139+
})
140+
141+
It("can print multiple logs", func() {
142+
log := internal.GinkgoLogrFunc(writer)
143+
log.Info("message", "key", 5)
144+
log.Error(errors.New("cake"), "planned failure", "key", "banana")
145+
Ω(string(out.Contents())).Should(Equal(" \"level\"=0 \"msg\"=\"message\" \"key\"=5\n \"msg\"=\"planned failure\" \"error\"=\"cake\" \"key\"=\"banana\"\n"))
139146
})
140147
})
141148
})

0 commit comments

Comments
 (0)
Please sign in to comment.