예제 #1
0
파일: stdlog_test.go 프로젝트: shazow/log
func TestGetFromFlags(t *testing.T) {
	logger := getLogger("info", "none")

	logger.Debug(logtest.Messages[log.Debug])
	logtest.AssertNotContain(t, testStream, logtest.Messages[log.Debug])

	logger.Info(logtest.Messages[log.Info])
	logtest.AssertContains(t, testStream, logtest.Messages[log.Info])
	logtest.AssertLineCount(t, testStream, 1)

	logger = getLogger("info", "error")

	logger.Info(logtest.Messages[log.Info])
	logtest.AssertNotContain(t, testStream, logtest.Messages[log.Info])

	logger.Error(logtest.Messages[log.Error])
	logtest.AssertContains(t, testStream, logtest.Messages[log.Error])
	logtest.AssertLineCount(t, testStream, 2)
}
예제 #2
0
파일: buflog_test.go 프로젝트: shazow/log
func TestBufferedLogging(t *testing.T) {
	logger, out := createLogger(log.Info, log.Error)

	logger.Debug(logtest.Messages[log.Debug])
	logtest.AssertNotContain(t, out, logtest.Messages[log.Debug])

	logger.Info(logtest.Messages[log.Info])
	logtest.AssertNotContain(t, out, logtest.Messages[log.Info])

	logger.Error(logtest.Messages[log.Error])
	logtest.AssertNotContain(t, out, logtest.Messages[log.Debug])
	logtest.AssertContains(t, out, logtest.Messages[log.Info])
	logtest.AssertContains(t, out, logtest.Messages[log.Error])

	logger.Warning(logtest.Messages[log.Warning])
	logtest.AssertContains(t, out, logtest.Messages[log.Warning])

	logger.Alert(logtest.Messages[log.Alert])
	logtest.AssertContains(t, out, logtest.Messages[log.Alert])

	logtest.AssertLineCount(t, out, 4)
}
예제 #3
0
파일: golog_test.go 프로젝트: shazow/log
func testLogThreshold(t *testing.T, level log.Level, isLoggedList map[log.Level]bool) {
	logger, out := createTestLogger(level)

	logger.Emergency(logtest.Messages[log.Emergency])
	logger.Alert(logtest.Messages[log.Alert])
	logger.Critical(logtest.Messages[log.Critical])
	logger.Error(logtest.Messages[log.Error])
	logger.Warning(logtest.Messages[log.Warning])
	logger.Notice(logtest.Messages[log.Notice])
	logger.Info(logtest.Messages[log.Info])
	logger.Debug(logtest.Messages[log.Debug])

	for level, isLogged := range isLoggedList {
		if isLogged {
			logtest.AssertContains(t, out, logtest.Messages[level])
		} else {
			logtest.AssertNotContain(t, out, logtest.Messages[level])
		}
	}
}