Beispiel #1
0
func main() {
	logger := gol.New()
	logger.Error("Hello worold")
	logger.Errorf("Some test: %v", map[string]int{"one": 1, "two": 2})

	err := gore.Newf("Hello %s", "world")
	gore.Append(err, "Foo bar")
	gore.Appendf(err, "Context %s", "info")
	logger.ErrorE(err)

	logger.ErrorE(errors.New("classic work!"))
}
Beispiel #2
0
func ExampleViewTexti_Gore() {
	t, _ := time.Parse("2006/01/02 15:04:05", "2015/01/11 15:04:05")
	record := &Record{
		Time:   t,
		Pid:    34572,
		Level:  ERROR,
		Caller: NewCaller(0),
	}

	err := gore.New("Some error")
	gore.Append(err, "step one")
	gore.Append(err, "step two")

	record.Body, record.Context = errorInfo(err)

	buf, _ := ViewText(record)

	fmt.Print(buf.String())
	// Output:
	// 34572 2015/01/11 15:04:05 ERROR example_view_test.go:35 gol.ExampleViewTexti_Gore [example_view_test.go:38 gol.ExampleViewTexti_Gore] Some error
	//       #0 [example_view_test.go:39 gol.ExampleViewTexti_Gore] step one
	//       #1 [example_view_test.go:40 gol.ExampleViewTexti_Gore] step two
}