MCPcopy
hub / github.com/sirupsen/logrus / ExampleJSONFormatter_CallerPrettyfier

Function ExampleJSONFormatter_CallerPrettyfier

example_custom_caller_test.go:12–28  ·  example_custom_caller_test.go::ExampleJSONFormatter_CallerPrettyfier
()

Source from the content-addressed store, hash-verified

10)
11
12func ExampleJSONFormatter_CallerPrettyfier() {
13 l := logrus.New()
14 l.SetReportCaller(true)
15 l.Out = os.Stdout
16 l.Formatter = &logrus.JSONFormatter{
17 DisableTimestamp: true,
18 CallerPrettyfier: func(f *runtime.Frame) (string, string) {
19 s := strings.Split(f.Function, ".")
20 funcname := s[len(s)-1]
21 _, filename := path.Split(f.File)
22 return funcname, filename
23 },
24 }
25 l.Info("example of custom format caller")
26 // Output:
27 // {"file":"example_custom_caller_test.go","func":"ExampleJSONFormatter_CallerPrettyfier","level":"info","msg":"example of custom format caller"}
28}

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
SetReportCallerMethod · 0.80
InfoMethod · 0.65

Tested by

no test coverage detected