From 22d0a2120ae97ef0567aeb7c434efbaecdc38886 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Tue, 20 Sep 2022 23:51:58 +0800 Subject: [PATCH] chore: replace fmt.Fprint (#2425) --- core/logx/rotatelogger.go | 4 +++- core/stat/alert.go | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) 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())