Fix: trim extra newline on Write method

This commit is contained in:
kayos@tcp.direct 2023-08-27 14:05:59 -07:00
parent 8ef7e87b22
commit faa4134799
Signed by: kayos
GPG Key ID: 4B841471B4BEE979

@ -3,6 +3,7 @@
package zwrap package zwrap
import ( import (
"bytes"
"fmt" "fmt"
"log" "log"
"strings" "strings"
@ -222,7 +223,7 @@ func (l *Logger) Warningf(format string, v ...interface{}) {
func (l *Logger) Write(p []byte) (n int, err error) { func (l *Logger) Write(p []byte) (n int, err error) {
l.RLock() l.RLock()
l.Logger.WithLevel(l.printLevel).Msg(string(p)) l.Logger.WithLevel(l.printLevel).Msg(string(bytes.TrimSuffix(p, []byte("\n"))))
l.RUnlock() l.RUnlock()
return len(p), nil return len(p), nil
} }