Exemplo n.º 1
0
Arquivo: color.go Projeto: gotips/log
func execColorizedExamples() {
	log.SetLevel(log.Lall)
	log.Info("default config")

	log.Colorized(true)
	log.Info("colorized config")

	log.Colorized(false)
	log.Error("close colorized config")
}
Exemplo n.º 2
0
func TestDefaultFormat(t *testing.T) {
	buf := bytes.NewBuffer(make([]byte, 4096))
	log.SetWriter(buf)

	msg := "this is a test message"
	log.Info(msg)
	if ok, _ := regexp.Match(`\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} -? ?info test/deeper/log_test.go:\d+ this is a test message`, buf.Bytes()); !ok {
		t.Logf("%s", buf.Bytes()) // 2016-01-24 19:41:19 info test/deeper/log_test.go:16 this is a test message
		t.FailNow()
	}
}
Exemplo n.º 3
0
func xTestPrint(t *testing.T) {
	file, err := os.OpenFile("test.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	log.SetWriter(file)

	for i := 0; i < 100e4; i++ {
		if i%1e4 == 0 {
			fmt.Println(i)
		}
		log.Info("can't load package: package lib: cannot find package `xxx` in any of")
	}

}
Exemplo n.º 4
0
func init() {
	Initialize(originId, appId, appSecret, token, encodingAESKey)
	log.Info("Initializing, please wait 5 seconds...")
	time.Sleep(5 * time.Second) // waiting to refresh token
}