-
Notifications
You must be signed in to change notification settings - Fork 10
/
logger.go
47 lines (35 loc) · 1 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
package rbac
import "fmt"
// Logger is interface for logger to be used in RBAC
type Logger interface {
Debugf(format string, args ...interface{})
Errorf(format string, args ...interface{})
}
// NullLogger is null logger
type NullLogger struct {
}
// NewNullLogger returns a new NullLogger
func NewNullLogger() Logger {
return &NullLogger{}
}
// Debugf is for debug logging
func (nl *NullLogger) Debugf(format string, args ...interface{}) {
}
// Errorf is for error logging
func (nl *NullLogger) Errorf(format string, args ...interface{}) {
}
// ConsoleLogger is console logger
type ConsoleLogger struct {
}
// NewConsoleLogger returns a new ConsoleLogger
func NewConsoleLogger() Logger {
return &ConsoleLogger{}
}
// Debugf is for debug logging
func (nl *ConsoleLogger) Debugf(format string, args ...interface{}) {
fmt.Printf("[DEBUG] "+format+"\n", args...)
}
// Errorf is for error logging
func (nl *ConsoleLogger) Errorf(format string, args ...interface{}) {
fmt.Printf("[ERROR] "+format+"\n", args...)
}