This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
std_log.go
64 lines (58 loc) · 1.71 KB
/
std_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
56
57
58
59
60
61
62
63
64
package gsimplelog
import (
"fmt"
)
func NewStdLogger(level int) (ILogger, error) {
return &StdLogger{
Level: level,
}, nil
}
type StdLogger struct {
Level int
}
func (s *StdLogger) SetLevel(level int) {
s.Level = level
}
func (s *StdLogger) Trace(params ...interface{}) {
if s.Level <= LogTrace {
fmt.Printf("%s %c[1;0;33m[TRACE]%c[0m %s\n", Now(), 0x1B, 0x1B, fmt.Sprint(params ...))
}
}
func (s *StdLogger) Debug(params ...interface{}) {
if s.Level <= LogDebug {
fmt.Printf("%s %c[1;0;34m[DEBUG]%c[0m %s\n", Now(), 0x1B, 0x1B, fmt.Sprint(params ...))
}
}
func (s *StdLogger) Info(params ...interface{}) {
if s.Level <= LogInfo {
fmt.Printf("%s %c[1;0;32m[INFO]%c[0m %s\n", Now(), 0x1B, 0x1B, fmt.Sprint(params ...))
}
}
func (s *StdLogger) Error(params ...interface{}) {
if s.Level <= LogError {
fmt.Printf("%s %c[1;0;31m[ERROR]%c[0m %s\n", Now(), 0x1B, 0x1B, fmt.Sprint(params ...))
}
}
func (s *StdLogger) Tracef(fromat string, params ...interface{}) {
if s.Level <= LogTrace {
fmt.Printf("%s %c[1;0;33m[TRACE]%c[0m %s\n", Now(), 0x1B, 0x1B, fmt.Sprintf(fromat, params...))
}
}
func (s *StdLogger) Debugf(fromat string, params ...interface{}) {
if s.Level <= LogDebug {
fmt.Printf("%s %c[1;0;34m[DEBUG]%c[0m %s\n", Now(), 0x1B, 0x1B, fmt.Sprintf(fromat, params...))
}
}
func (s *StdLogger) Infof(fromat string, params ...interface{}) {
if s.Level <= LogInfo {
fmt.Printf("%s %c[1;0;32m[INFO]%c[0m %s\n", Now(), 0x1B, 0x1B, fmt.Sprintf(fromat, params...))
}
}
func (s *StdLogger) Errorf(fromat string, params ...interface{}) {
if s.Level <= LogError {
fmt.Printf("%s %c[1;0;31m[ERROR]%c[0m %s\n", Now(), 0x1B, 0x1B, fmt.Sprintf(fromat, params...))
}
}
func (s *StdLogger) Close() error {
return nil
}