-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.go
49 lines (42 loc) · 1.37 KB
/
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
package ping
import (
"io/ioutil"
"log"
"os"
)
var (
LogLevel *LogSeverity
)
type LogSeverity struct {
Fail *log.Logger
Info *log.Logger
Message *log.Logger
}
func (logSeverity *LogSeverity) Default() {
LogLevel = &LogSeverity{
Info: log.New(ioutil.Discard, "[Verbose]: ", log.LstdFlags|log.Lshortfile),
Fail: log.New(os.Stderr, "[Error]: ", log.LstdFlags|log.Lshortfile),
Message: log.New(ioutil.Discard, "[Debug]: ", log.LstdFlags|log.Lshortfile),
}
}
func (logSeverity *LogSeverity) Verbose() {
LogLevel = &LogSeverity{
Info: log.New(os.Stdout, "[Verbose]: ", log.LstdFlags|log.Lshortfile),
Fail: log.New(os.Stderr, "[Error]: ", log.LstdFlags|log.Lshortfile),
Message: log.New(ioutil.Discard, "[Debug]: ", log.LstdFlags|log.Lshortfile),
}
}
func (logSeverity *LogSeverity) Debug() {
LogLevel = &LogSeverity{
Info: log.New(os.Stdout, "[Verbose]: ", log.LstdFlags|log.Lshortfile),
Fail: log.New(os.Stderr, "[Error]: ", log.LstdFlags|log.Lshortfile),
Message: log.New(os.Stdout, "[Debug]: ", log.LstdFlags|log.Lshortfile),
}
}
func (logSeverity *LogSeverity) Silent() {
LogLevel = &LogSeverity{
Info: log.New(ioutil.Discard, "[Verbose]: ", log.LstdFlags|log.Lshortfile),
Fail: log.New(ioutil.Discard, "[Error]: ", log.LstdFlags|log.Lshortfile),
Message: log.New(ioutil.Discard, "[Debug]: ", log.LstdFlags|log.Lshortfile),
}
}