Upgrading dependencies to include logrus.
This commit is contained in:
parent
bc28198c2d
commit
c03901c0f1
379 changed files with 90030 additions and 47 deletions
36
vendor/github.com/sirupsen/logrus/example_global_hook_test.go
generated
vendored
Normal file
36
vendor/github.com/sirupsen/logrus/example_global_hook_test.go
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
package logrus_test
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
mystring string
|
||||
)
|
||||
|
||||
type GlobalHook struct {
|
||||
}
|
||||
|
||||
func (h *GlobalHook) Levels() []logrus.Level {
|
||||
return logrus.AllLevels
|
||||
}
|
||||
|
||||
func (h *GlobalHook) Fire(e *logrus.Entry) error {
|
||||
e.Data["mystring"] = mystring
|
||||
return nil
|
||||
}
|
||||
|
||||
func Example() {
|
||||
l := logrus.New()
|
||||
l.Out = os.Stdout
|
||||
l.Formatter = &logrus.TextFormatter{DisableTimestamp: true, DisableColors: true}
|
||||
l.AddHook(&GlobalHook{})
|
||||
mystring = "first value"
|
||||
l.Info("first log")
|
||||
mystring = "another value"
|
||||
l.Info("second log")
|
||||
// Output:
|
||||
// level=info msg="first log" mystring="first value"
|
||||
// level=info msg="second log" mystring="another value"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue