-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
45 lines (37 loc) · 1.06 KB
/
logger.go
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
41
42
43
44
45
package cogol
import (
"fmt"
"github.com/fatih/color"
)
type Logger interface {
Info(text string)
Infof(format string, args ...interface{})
Error(text string)
Errorf(format string, args ...interface{})
}
func newDefaultLogger(test *test) Logger {
return defaultLogger{
test: test,
}
}
type defaultLogger struct {
test *test
}
func (l defaultLogger) Info(text string) {
tag := color.HiBlueString("\t\tINFO")
l.test.logs = append(l.test.logs, fmt.Sprintf("%v %v\n\n", tag, text))
}
func (l defaultLogger) Infof(format string, a ...interface{}) {
tag := color.HiBlueString("\t\tINFO")
text := fmt.Sprintf(format, a...)
l.test.logs = append(l.test.logs, fmt.Sprintf("%v %v\n\n", tag, text))
}
func (l defaultLogger) Error(text string) {
tag := color.HiRedString("\t\tERROR")
l.test.logs = append(l.test.logs, fmt.Sprintf("%v %v\n\n", tag, text))
}
func (l defaultLogger) Errorf(format string, a ...interface{}) {
tag := color.HiRedString("\t\tERROR")
text := fmt.Sprintf(format, a...)
l.test.logs = append(l.test.logs, fmt.Sprintf("%v %v\n\n", tag, text))
}