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

Function ExampleDefaultFieldHook

example_default_field_value_test.go:22–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20}
21
22func ExampleDefaultFieldHook() {
23 l := logrus.New()
24 l.Out = os.Stdout
25 l.Formatter = &logrus.TextFormatter{DisableTimestamp: true, DisableColors: true}
26
27 l.AddHook(&DefaultFieldHook{GetValue: func() string { return "with its default value" }})
28 l.Info("first log")
29 // Output:
30 // level=info msg="first log" aDefaultField="with its default value"
31}

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
AddHookMethod · 0.80
InfoMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…