MCPcopy Create free account
hub / github.com/cloudwan/gohan / Format

Method Format

log/jsonformatter.go:16–30  ·  view source on GitHub ↗

Format formats message to JSON format

(calldepth int, record *logging.Record, output io.Writer)

Source from the content-addressed store, hash-verified

14
15//Format formats message to JSON format
16func (f *jsonFormatter) Format(calldepth int, record *logging.Record, output io.Writer) error {
17 result := map[string]interface{}{
18 "timestamp": record.Time,
19 "log_level": record.Level.String(),
20 "log_type": "log",
21 "msg": record.Message(),
22 "component_name": record.Module,
23 }
24 resultJSON, err := json.Marshal(result)
25 if err != nil {
26 return err
27 }
28 fmt.Fprintf(output, "%s\n", resultJSON)
29 return nil
30}

Callers 1

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected