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

Function ExampleGlobalHook

example_global_hook_test.go:25–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23}
24
25func ExampleGlobalHook() {
26 l := logrus.New()
27 l.Out = os.Stdout
28 l.Formatter = &logrus.TextFormatter{DisableTimestamp: true, DisableColors: true}
29 l.AddHook(&GlobalHook{})
30 mystring = "first value"
31 l.Info("first log")
32 mystring = "another value"
33 l.Info("second log")
34 // Output:
35 // level=info msg="first log" mystring="first value"
36 // level=info msg="second log" mystring="another value"
37}

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…