diff --git a/core/logx/rotatelogger.go b/core/logx/rotatelogger.go index 5944d593..0b8f0b14 100644 --- a/core/logx/rotatelogger.go +++ b/core/logx/rotatelogger.go @@ -115,7 +115,9 @@ func (r *DailyRotateRule) OutdatedFiles() []string { var buf strings.Builder boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(dateFormat) - fmt.Fprintf(&buf, "%s%s%s", r.filename, r.delimiter, boundary) + buf.WriteString(r.filename) + buf.WriteString(r.delimiter) + buf.WriteString(boundary) if r.gzip { buf.WriteString(gzipExt) } diff --git a/core/stat/alert.go b/core/stat/alert.go index db604dad..e53c7e31 100644 --- a/core/stat/alert.go +++ b/core/stat/alert.go @@ -46,14 +46,14 @@ func Report(msg string) { if fn != nil { reported := lessExecutor.DoOrDiscard(func() { var builder strings.Builder - fmt.Fprintf(&builder, "%s\n", time.Now().Format(timeFormat)) + builder.WriteString(fmt.Sprintln(time.Now().Format(timeFormat))) if len(clusterName) > 0 { - fmt.Fprintf(&builder, "cluster: %s\n", clusterName) + builder.WriteString(fmt.Sprintf("cluster: %s\n", clusterName)) } - fmt.Fprintf(&builder, "host: %s\n", sysx.Hostname()) + builder.WriteString(fmt.Sprintf("host: %s\n", sysx.Hostname())) dp := atomic.SwapInt32(&dropped, 0) if dp > 0 { - fmt.Fprintf(&builder, "dropped: %d\n", dp) + builder.WriteString(fmt.Sprintf("dropped: %d\n", dp)) } builder.WriteString(strings.TrimSpace(msg)) fn(builder.String())