()
| 23 | } |
| 24 | |
| 25 | func 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 | } |