From d8724cb122327327784f182f23cba47817d5e1b8 Mon Sep 17 00:00:00 2001 From: Gabriel Cruz Date: Mon, 6 Jul 2020 21:34:09 +0200 Subject: [PATCH] Add error returning to writeln --- logs/conn.go | 5 ++++- logs/logger.go | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/logs/conn.go b/logs/conn.go index 5201f30e..74c458ab 100644 --- a/logs/conn.go +++ b/logs/conn.go @@ -63,7 +63,10 @@ func (c *connWriter) WriteMsg(when time.Time, msg string, level int) error { defer c.innerWriter.Close() } - c.lg.writeln(when, msg) + _, err := c.lg.writeln(when, msg) + if err != nil { + return err + } return nil } diff --git a/logs/logger.go b/logs/logger.go index c7cf8a56..a28bff6f 100644 --- a/logs/logger.go +++ b/logs/logger.go @@ -30,11 +30,12 @@ func newLogWriter(wr io.Writer) *logWriter { return &logWriter{writer: wr} } -func (lg *logWriter) writeln(when time.Time, msg string) { +func (lg *logWriter) writeln(when time.Time, msg string) (int, error) { lg.Lock() h, _, _ := formatTimeHeader(when) - lg.writer.Write(append(append(h, msg...), '\n')) + n, err := lg.writer.Write(append(append(h, msg...), '\n')) lg.Unlock() + return n, err } const (