示例#1
0
func Example_NewLog() {
	defer logim.Close()
	l := logim.NewLog()
	l.Infof("hi %d", 10)
	l.With("baz", 5).With("bar", 7).Warnf("problem %s", "oh oh")
	l.Errorf("bye %d", 20)
}
示例#2
0
func Example_NewActivityWithConfig() {
	defer logim.Close()
	l := logim.NewActivityWithConfig(logim.Config{
		IDGenerator:  &predictableIDGenerator{},
		NowGenerator: &predictableNowGenerator{},
	})
	defer l.Close()

	l.Set("RequestID", 1234)
	l.Infof("hi %d", 10)
	l.With("baz", 5).With("bar", 7).Warnf("problem %s", "oh oh")
	l.Errorf("bye %d", 20)

	// Output:
	//============
	//ActivityID: 1
	//Level: ERRR
	//Time: Jan  1 00:00:01, 4s
	//   [RequestID]=1234
	//events:
	//0   (logim_example_test.go:30) On Jan  1 00:00:02 (ev#2) [INFO]
	//hi 10
	//1   (logim_example_test.go:31) On Jan  1 00:00:03 (ev#3) [WARN]
	//problem oh oh
	//   [baz]=5
	//   [bar]=7
	//2   (logim_example_test.go:32) On Jan  1 00:00:04 (ev#4) [ERRR]
	//bye 20
}
示例#3
0
func Example_NewActivity() {
	defer logim.Close()
	l := logim.NewActivity()
	defer l.Close()

	l.Set("RequestID", 1234)
	l.Infof("hi %d", 10)
	l.With("baz", 5).With("bar", 7).Warnf("problem %s", "oh oh")
	l.Errorf("bye %d", 20)
}