示例#1
0
func TestTagged(t *testing.T) {
	//create buffer
	log, buf := createLogger()

	log.Print("footag", "foo")
	compare(t, buf, "")

	log.Enable("footag")
	log.Print("footag", "foo")
	compare(t, buf, "foo\n")

	log.Print("bartag", "bar")
	compare(t, buf, "")

	log.Enable("bartag")
	log.Print("bartag", "bar")
	compare(t, buf, "bar\n")
}
示例#2
0
func TestDisableTag(t *testing.T) {
	log, buf := createLogger()

	log.Enable("footag")
	log.Print("footag", "foo")
	compare(t, buf, "foo\n")

	log.Disable("footag")
	log.Print("footag", "foo")
	compare(t, buf, "")
}
示例#3
0
func TestMultitag(t *testing.T) {
	log, buf := createLogger()

	log.Enable("footag")
	log.Enable("bartag")
	log.Print("notag, other", "foo")
	compare(t, buf, "")

	log.Print("notag, footag", "foo")
	compare(t, buf, "foo\n")

	log.Print("footag, bartag", "foo")
	compare(t, buf, "foo\n")

	log.Print("footag,bartag", "foo")
	compare(t, buf, "foo\n")

	log.Disable("footag,bartag")
	log.Print("footag", "foo")
	compare(t, buf, "")
	log.Print("bartag", "foo")
	compare(t, buf, "")
}