-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
49 lines (38 loc) · 928 Bytes
/
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
46
47
48
49
package rlock
import (
"log"
"os"
)
type logger interface {
Printf(format string, v ...any)
Println(v ...any)
}
type logx struct {
infoL logger
errorL logger
debugL logger
}
func newLogger() *logx {
Info := log.New(os.Stdout, "[Info]: ", log.Ldate|log.Ltime|log.Lshortfile)
Error := log.New(os.Stdout, "[Error]: ", log.Ldate|log.Ltime|log.Lshortfile)
Debug := log.New(os.Stdout, "[Debug]: ", log.Ldate|log.Ltime|log.Lshortfile)
return &logx{infoL: Info, errorL: Error, debugL: Debug}
}
func (l *logx) Info(v ...any) {
l.infoL.Println(v...)
}
func (l *logx) Infof(format string, v ...any) {
l.infoL.Printf(format, v...)
}
func (l *logx) Error(v ...any) {
l.errorL.Println(v...)
}
func (l *logx) Errorf(format string, v ...any) {
l.errorL.Printf(format, v...)
}
func (l *logx) Debug(v ...any) {
l.debugL.Println(v...)
}
func (l *logx) Debugf(format string, v ...any) {
l.debugL.Printf(format, v...)
}