1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-24 12:40:55 +00:00

Add error returning to writeln

This commit is contained in:
Gabriel Cruz 2020-07-06 21:34:09 +02:00
parent fc56c562db
commit d8724cb122
No known key found for this signature in database
GPG Key ID: C1818F9BA91EBD38
2 changed files with 7 additions and 3 deletions

View File

@ -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
}

View File

@ -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 (