MCPcopy Index your code
hub / github.com/foxcpp/maddy / formatMsg

Method formatMsg

framework/log/log.go:171–191  ·  view source on GitHub ↗
(msg string, fields map[string]interface{})

Source from the content-addressed store, hash-verified

169}
170
171func (l *Logger) formatMsg(msg string, fields map[string]interface{}) string {
172 formatted := strings.Builder{}
173
174 formatted.WriteString(msg)
175 formatted.WriteRune('\t')
176
177 if len(l.Fields)+len(fields) != 0 {
178 if fields == nil {
179 fields = make(map[string]interface{})
180 }
181 for k, v := range l.Fields {
182 fields[k] = v
183 }
184 if err := marshalOrderedJSON(&formatted, fields); err != nil {
185 // Fallback to printing the message with minimal processing.
186 return fmt.Sprintf("[BROKEN FORMATTING: %v] %v %+v", err, msg, fields)
187 }
188 }
189
190 return formatted.String()
191}
192
193type Formatter interface {
194 FormatLog() string

Callers 8

DebugfMethod · 0.95
DebuglnMethod · 0.95
PrintfMethod · 0.95
PrintlnMethod · 0.95
MsgMethod · 0.95
ErrorMethod · 0.95
DebugMsgMethod · 0.95
WriteMethod · 0.80

Calls 2

marshalOrderedJSONFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected