Skip to content

Commit ebc1b17

Browse files
committed
log: append newline to msgs when missing
1 parent e971551 commit ebc1b17

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

intra/log/fconsole.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package log
22

33
import (
4+
"bytes"
45
"io"
56
"os"
67
"syscall"
78
"unsafe"
89
)
910

11+
var newline = []byte{'\n'}
12+
1013
type fconsole struct {
1114
// takes ownership of w
1215
w *os.File
@@ -65,6 +68,10 @@ func (f *fconsole) write(m Logmsg) error {
6568
p := unsafe.StringData(m)
6669
b := unsafe.Slice(p, len(m))
6770
n, err := w.Write(b)
71+
// go.dev/play/p/NbJimcpoS0o
72+
if !bytes.HasSuffix(b, newline) {
73+
w.Write(newline)
74+
}
6875
if err != nil {
6976
if err == syscall.EAGAIN || err == syscall.EWOULDBLOCK || err == syscall.EINTR {
7077
// non-blocking write would block; drop the log

0 commit comments

Comments
 (0)