13
func TestDefaultLogLevel(t *testing.T) {
14
if log_level != _DEFAULT_LOG_LEVEL {t.Error("Test failed, expected DEFAULT_LOG_LEVEL level.")}
17
func TestSetLogLevel(t *testing.T) {
19
defer SetLogLevel("DEFAULT_LOG_LEVEL")
20
if log_level != _DEBUG {t.Error("Test failed, expected DEBUG level.")}
22
if log_level != _INFO {t.Error("Test failed, expected INFO level.")}
24
if log_level != _WARN {t.Error("Test failed, expected WARN level.")}
26
if log_level != _ERROR {t.Error("Test failed, expected ERROR level.")}
30
testFormat = "test format %s"
31
testArgument = "test string 1"
32
expectedRegexp = regexp.MustCompile(".*" + fmt.Sprintf(testFormat, testArgument) + "\n$")
36
func TestLogf(t *testing.T) {
37
buf := new(bytes.Buffer)
39
defer log.SetOutput(os.Stderr)
41
defer SetLogLevel("DEFAULT_LOG_LEVEL")
43
logf(_DEBUG, testFormat, testArgument)
45
matched := expectedRegexp.MatchString(line)
47
t.Errorf("log output should match %q and is %q.", expectedRegexp, line)
51
func TestLogfUsesLogLevel(t *testing.T) {
52
buf := new(bytes.Buffer)
54
defer log.SetOutput(os.Stderr)
56
defer SetLogLevel("DEFAULT_LOG_LEVEL")
58
logf(_DEBUG, testFormat, testArgument)
61
if line != expectedLine {
62
t.Errorf("log output should match %q and is %q.", expectedLine, line)