@@ -21,9 +21,9 @@ const (
2121
2222// Format building log message.
2323func (f * Config ) Format (entry * logrus.Entry ) ([]byte , error ) {
24- output := f .LogFormat
25- if output == "" {
26- output = defaultLogFormat
24+ format := f .LogFormat
25+ if format == "" {
26+ format = defaultLogFormat
2727 }
2828
2929 timestampFormat := f .TimestampFormat
@@ -45,10 +45,14 @@ func (f *Config) Format(entry *logrus.Entry) ([]byte, error) {
4545 fieldPattern = start + logFieldColor + fieldPattern + end
4646 }
4747
48- output = strings .Replace (output , "%time%" , entry .Time .Format (timestampFormat ), 1 )
49- output = strings .Replace (output , "%msg%" , m , 1 )
50- output = strings .Replace (output , "%lvl%" , l , 1 )
51- output = strings .Replace (output , "%emoji%" , emoji , 1 )
48+ replacer := strings .NewReplacer (
49+ "%time%" , entry .Time .Format (timestampFormat ),
50+ "%msg%" , m ,
51+ "%lvl%" , l ,
52+ "%emoji%" , emoji ,
53+ )
54+
55+ output := replacer .Replace (format )
5256
5357 for k , val := range entry .Data {
5458 switch val := val .(type ) {
0 commit comments