-
Notifications
You must be signed in to change notification settings - Fork 47
/
logger.go
48 lines (40 loc) · 1.14 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
/*
Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
Use of this source code is governed by a MIT license that can be found in the LICENSE file.
*/
package configutil
// MaybeInfof writes an info message if the logger is set.
func MaybeInfof(log Logger, format string, args ...interface{}) {
if log == nil {
return
}
log.Infof(format, args...)
}
// MaybeDebugf writes a debug message if the logger is set.
func MaybeDebugf(log Logger, format string, args ...interface{}) {
if log == nil {
return
}
log.Debugf(format, args...)
}
// MaybeWarningf writes a debug message if the logger is set.
func MaybeWarningf(log Logger, format string, args ...interface{}) {
if log == nil {
return
}
log.Warningf(format, args...)
}
// MaybeErrorf writes an error message if the logger is set.
func MaybeErrorf(log Logger, format string, args ...interface{}) {
if log == nil {
return
}
log.Errorf(format, args...)
}
// Logger is a type that can satisfy the configutil logger interface.
type Logger interface {
Infof(string, ...interface{})
Debugf(string, ...interface{})
Warningf(string, ...interface{})
Errorf(string, ...interface{})
}