mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 12:17:53 +08:00
fix issue in logging file rotation
This commit is contained in:
parent
54a2b13825
commit
5be30b3684
@ -233,6 +233,7 @@ func (l *Logger) printToFile(now time.Time, buffer *bytes.Buffer) {
|
|||||||
if l.config.RotateSize > 0 {
|
if l.config.RotateSize > 0 {
|
||||||
stat, err := file.Stat()
|
stat, err := file.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
file.Close()
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if stat.Size() > l.config.RotateSize {
|
if stat.Size() > l.config.RotateSize {
|
||||||
@ -241,10 +242,10 @@ func (l *Logger) printToFile(now time.Time, buffer *bytes.Buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err := file.Write(buffer.Bytes()); err != nil {
|
if _, err := file.Write(buffer.Bytes()); err != nil {
|
||||||
defer file.Close()
|
file.Close()
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer file.Close()
|
file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// getFilePointer retrieves and returns a file pointer from file pool.
|
// getFilePointer retrieves and returns a file pointer from file pool.
|
||||||
|
Loading…
Reference in New Issue
Block a user