MCPcopy Index your code
hub / github.com/pterm/pterm / renderJSON

Method renderJSON

logger.go:379–392  ·  view source on GitHub ↗
(level LogLevel, msg string, args []LoggerArgument)

Source from the content-addressed store, hash-verified

377}
378
379func (l Logger) renderJSON(level LogLevel, msg string, args []LoggerArgument) string {
380 m := l.argsToMap(args)
381
382 m["level"] = level.String()
383 m["timestamp"] = time.Now().Format(l.TimeFormat)
384 m["msg"] = msg
385
386 if file, line := l.getCallerInfo(); file != "" {
387 m["caller"] = Sprintf("%s:%d", file, line)
388 }
389
390 b, _ := json.Marshal(m)
391 return string(b)
392}
393
394func (l Logger) argsToMap(args []LoggerArgument) map[string]any {
395 m := make(map[string]any)

Callers 1

printMethod · 0.95

Calls 4

argsToMapMethod · 0.95
getCallerInfoMethod · 0.95
SprintfFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected