-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlog.go
47 lines (37 loc) · 1.18 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
package imapsql
import (
"log"
"strconv"
)
type globalLogger struct{}
func (globalLogger) Printf(format string, v ...interface{}) {
log.Printf(format, v...)
}
func (globalLogger) Println(v ...interface{}) {
log.Println(v...)
}
func (globalLogger) Debugf(format string, v ...interface{}) {
log.Printf(format, v...)
}
func (globalLogger) Debugln(v ...interface{}) {
log.Println(v...)
}
type DummyLogger struct{}
func (DummyLogger) Printf(format string, v ...interface{}) {}
func (DummyLogger) Println(v ...interface{}) {}
func (DummyLogger) Debugf(format string, v ...interface{}) {}
func (DummyLogger) Debugln(v ...interface{}) {}
func (b *Backend) logUserErr(u *User, err error, when string, args ...interface{}) {
if err == nil {
return
}
b.Opts.Log.Printf("%s %v: %v \t{\"username\":%s,\"uid\":%d}",
when, args, err, strconv.Quote(u.username), u.id)
}
func (b *Backend) logMboxErr(m *Mailbox, err error, when string, args ...interface{}) {
if err == nil {
return
}
b.Opts.Log.Printf("%s %v: %v \t{\"mbox\":%s,\"mboxId\":%d,\"username\":%s,\"uid\":%d}",
when, args, err, strconv.Quote(m.name), m.id, strconv.Quote(m.user.username), m.user.id)
}