Revert "Use Copyfile() to back up the log, so as not to continue writing the log to the old file because the old fd is not closed #1366"

This reverts commit a3bab8db55.
This commit is contained in:
flead
2022-01-08 12:10:39 +08:00
parent a3bab8db55
commit 6232c873b8

View File

@ -100,13 +100,9 @@ func (l *Logger) doRotateFile(ctx context.Context, filePath string) error {
}
}
intlog.Printf(ctx, "rotating file by size from %s to %s", filePath, newFilePath)
if err := gfile.CopyFile(filePath, newFilePath); err != nil {
intlog.Error(ctx, "copy file to: ", newFilePath, err)
if err := gfile.Rename(filePath, newFilePath); err != nil {
return err
}
gfile.Truncate(filePath, 0)
return nil
}