Ejemplo n.º 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")
}
Ejemplo 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, "")
}
Ejemplo n.º 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, "")
}