chore: replace fmt.Fprint (#2425)

master
Kevin Wan 2 years ago committed by GitHub
parent 68e15360c2
commit 22d0a2120a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -115,7 +115,9 @@ func (r *DailyRotateRule) OutdatedFiles() []string {
var buf strings.Builder var buf strings.Builder
boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(dateFormat) 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 { if r.gzip {
buf.WriteString(gzipExt) buf.WriteString(gzipExt)
} }

@ -46,14 +46,14 @@ func Report(msg string) {
if fn != nil { if fn != nil {
reported := lessExecutor.DoOrDiscard(func() { reported := lessExecutor.DoOrDiscard(func() {
var builder strings.Builder 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 { 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) dp := atomic.SwapInt32(&dropped, 0)
if dp > 0 { if dp > 0 {
fmt.Fprintf(&builder, "dropped: %d\n", dp) builder.WriteString(fmt.Sprintf("dropped: %d\n", dp))
} }
builder.WriteString(strings.TrimSpace(msg)) builder.WriteString(strings.TrimSpace(msg))
fn(builder.String()) fn(builder.String())

Loading…
Cancel
Save