-
Notifications
You must be signed in to change notification settings - Fork 26
/
logger.go
52 lines (42 loc) · 1.11 KB
/
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
50
51
52
package qb
import "log"
// These are the log flags qb can use
const (
// LDefault is the default flag that logs nothing
LDefault LogFlags = 0
// LQuery Flag to log queries
LQuery LogFlags = 1 << iota
// LBindings Flag to log bindings
LBindings
)
// LogFlags is the type we use for flags that can be passed
// to the logger
type LogFlags uint
// Logger is the std logger interface of the qb engine
type Logger interface {
Print(...interface{})
Printf(string, ...interface{})
Println(...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
Fatalln(...interface{})
Panic(...interface{})
Panicf(string, ...interface{})
Panicln(...interface{})
LogFlags() LogFlags
SetLogFlags(LogFlags)
}
// DefaultLogger is the default logger of qb engine unless engine.SetLogger() is not called
type DefaultLogger struct {
logFlags LogFlags
*log.Logger
}
// SetLogFlags sets the logflags
// It is for changing engine log flags
func (l *DefaultLogger) SetLogFlags(logFlags LogFlags) {
l.logFlags = logFlags
}
// LogFlags gets the logflags as an int
func (l *DefaultLogger) LogFlags() LogFlags {
return l.logFlags
}