()
| 10 | ) |
| 11 | |
| 12 | func 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 | } |
nothing calls this directly
no test coverage detected