@@ -114,6 +114,12 @@ func runtimeBacktrace(skip int) (string, int) {
114114}
115115
116116func (l * tlogger ) printWithInfos (file string , line int , now time.Time , err error , s severity.Severity , msg string , kvList []interface {}) {
117+ // The message is always quoted, even if it contains line breaks.
118+ // If developers want multi-line output, they should use a small, fixed
119+ // message and put the multi-line output into a value.
120+ qMsg := make ([]byte , 0 , 1024 )
121+ qMsg = strconv .AppendQuote (qMsg , msg )
122+
117123 // Only create a new buffer if we don't have one cached.
118124 b := buffer .GetBuffer ()
119125 defer buffer .PutBuffer (b )
@@ -124,10 +130,8 @@ func (l *tlogger) printWithInfos(file string, line int, now time.Time, err error
124130 }
125131 b .FormatHeader (s , file , line , now )
126132
127- // The message is always quoted, even if it contains line breaks.
128- // If developers want multi-line output, they should use a small, fixed
129- // message and put the multi-line output into a value.
130- b .WriteString (strconv .Quote (msg ))
133+ b .Write (qMsg )
134+
131135 if err != nil {
132136 serialize .KVFormat (& b .Buffer , "err" , err )
133137 }
0 commit comments