-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlogger.go
More file actions
36 lines (30 loc) · 782 Bytes
/
Copy pathlogger.go
File metadata and controls
36 lines (30 loc) · 782 Bytes
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
package gorm_ex
import (
"log"
"os"
)
type consoleLogger struct {
info *log.Logger
warn *log.Logger
error *log.Logger
}
func newConsoleLogger() *consoleLogger {
return &consoleLogger{
info:log.New(os.Stdout, "info", log.LstdFlags),
warn:log.New(os.Stdout, "warn", log.LstdFlags),
error:log.New(os.Stdout, "error", log.LstdFlags),
}
}
func(cl *consoleLogger) LogInfoc(category, message string) {
cl.info.Println( category, message)
}
func(cl *consoleLogger) LogWarnc(category string, err error, message string) {
if err == nil{
cl.warn.Println(category, message)
} else {
cl.warn.Println(category, err.Error(), message)
}
}
func(cl *consoleLogger) LogErrorc(category string, err error, message string) {
cl.error.Println(category, err.Error(), message)
}