forked from exoscale/cert-manager-webhook-exoscale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.go
32 lines (26 loc) · 770 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
package main
import "log"
// Logger is a thin wrapper around stdlib.log with just 2 levels (info & debug).
type Logger struct {
Verbose bool
}
// Info simply runs log.Println with info tag.
func (l Logger) Info(args ...any) {
log.Println(append([]any{"[INFO]"}, args...)...)
}
// Info simply runs log.Printf with info tag.
func (l Logger) Infof(format string, args ...any) {
log.Printf("[INFO] "+format, args...)
}
// Debug runs log.Println with debug tag if Verbose is true.
func (l Logger) Debug(args ...any) {
if l.Verbose {
log.Println(append([]any{"[DEBUG]"}, args...)...)
}
}
// Debug runs log.Printf with debug tag if Verbose is true.
func (l Logger) Debugf(format string, args ...any) {
if l.Verbose {
log.Printf("[DEBUG] "+format, args...)
}
}