优化快捷方法&处理重复打印的BUG

This commit is contained in:
Yun
2024-04-21 12:23:26 +08:00
parent 864b1ae117
commit 328dadb308
4 changed files with 64 additions and 5 deletions
+10 -4
View File
@@ -15,9 +15,15 @@ func (l *Logger) write(event string, b []byte) (n int, err error) {
err = io.ErrShortWrite
}
if err != nil {
// 强制更新
l.getFile(event, true)
// 强制更新 & 再次写入
f, err := l.getFile(event, true)
if err == nil {
f.Write(b)
}
}
d := append(l.option.drivers, f)
return io.MultiWriter(d...).Write(b)
if len(l.option.drivers) > 0 {
io.MultiWriter(l.option.drivers...).Write(b)
}
return n, err
}