-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
55 lines (48 loc) · 845 Bytes
/
log.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
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"os"
)
var report_fmt = `----------------------------------------
test pass: %d
test fail: %d
Overall: %s
----------------------------------------
`
//TODO use logger
func KInfo(text ...interface{}) {
if verbose {
fmt.Print("INF:")
fmt.Println(text...)
}
}
func KError(text ...interface{}) {
fmt.Print("ERR:")
fmt.Println(text...)
os.Exit(2)
}
func KWarning(text ...interface{}) {
fmt.Print("WRN:")
fmt.Println(text...)
}
func KPass(text ...interface{}) {
fmt.Print("## PASS:")
fmt.Println(text...)
passcount++
}
func KFail(text ...interface{}) {
fmt.Print("## FAIL:")
fmt.Println(text...)
kpass_val = false
passfail++
}
func Report() {
overall := "PASS"
if !kpass_val {
overall = "FAIL"
}
fmt.Printf(report_fmt, passcount, passfail, overall)
if !kpass_val {
os.Exit(2)
}
}