From ce197680b509f01f0e6a4ca1808f5fda0233dad3 Mon Sep 17 00:00:00 2001 From: evilolipop Date: Tue, 5 Mar 2024 17:45:27 +0800 Subject: [PATCH] refactor: make rotate private --- rotate_file.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rotate_file.go b/rotate_file.go index 69e6df5..80436d7 100644 --- a/rotate_file.go +++ b/rotate_file.go @@ -36,7 +36,7 @@ func NewRotateFile(directory string, basename string, rotateSize int, opts ...Op opt(rf) } - rf.Rotate() + rf.rotate() return rf, nil } @@ -46,13 +46,13 @@ func (r *RotateFile) Write(p []byte) (int, error) { r.written += n if r.written > r.rotateSize { - r.Rotate() + r.rotate() } else { r.count++ if r.count >= r.checkEveryN { r.count = 0 if time.Now().After(r.lastRotate.Add(r.rotateInterval)) { - r.Rotate() + r.rotate() } } } @@ -69,7 +69,7 @@ func (r *RotateFile) logFileName() (string, time.Time) { return r.filepath + "." + now.Format("20060102-150405.000000000") + "." + hostname + "." + fmt.Sprint(os.Getpid()) + ".log", now } -func (r *RotateFile) Rotate() { +func (r *RotateFile) rotate() { filename, now := r.logFileName() if now.After(r.lastRotate) {