-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathlogger_test.go
More file actions
40 lines (35 loc) · 899 Bytes
/
logger_test.go
File metadata and controls
40 lines (35 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package logger
import (
"os"
"testing"
"time"
)
func TestFileLogger(t *testing.T) {
f, err := os.Create("foo.log")
if err != nil {
t.Fatal(err)
}
defer func() { _ = f.Close() }()
l := NewFileLogger(f)
l.SetLevel(LevelDebug)
generateLogEntries(l)
}
func TestConsoleLogger(t *testing.T) {
l := NewConsoleLogger(true, nil)
l.SetLevel(LevelDebug)
generateLogEntries(l)
}
func generateLogEntries(l Logger) {
l.Log(time.Now(), LevelCritical, "test")
l.Log(time.Now(), LevelError, "test")
l.Log(time.Now(), LevelWarning, "test")
l.Log(time.Now(), LevelInfo, "test")
l.Log(time.Now(), LevelDebug, "test")
l.Log(time.Now(), LevelStderr, "test")
l.Log(time.Now(), LevelStdout, "test")
l.Log(time.Now(), LevelPass, "test")
l.Log(time.Now(), LevelFail, "test")
l.Log(time.Now(), LevelSkip, "test")
l.Log(time.Now(), LevelCancel, "test")
l.Log(time.Now(), LevelSummary, "test")
}