github.com/blend/go-sdk@v1.20220411.3/configutil/logger.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package configutil 9 10 // MaybeInfof writes an info message if the logger is set. 11 func MaybeInfof(log Logger, format string, args ...interface{}) { 12 if log == nil { 13 return 14 } 15 log.Infof(format, args...) 16 } 17 18 // MaybeDebugf writes a debug message if the logger is set. 19 func MaybeDebugf(log Logger, format string, args ...interface{}) { 20 if log == nil { 21 return 22 } 23 log.Debugf(format, args...) 24 } 25 26 // MaybeWarningf writes a debug message if the logger is set. 27 func MaybeWarningf(log Logger, format string, args ...interface{}) { 28 if log == nil { 29 return 30 } 31 log.Warningf(format, args...) 32 } 33 34 // MaybeErrorf writes an error message if the logger is set. 35 func MaybeErrorf(log Logger, format string, args ...interface{}) { 36 if log == nil { 37 return 38 } 39 log.Errorf(format, args...) 40 } 41 42 // Logger is a type that can satisfy the configutil logger interface. 43 type Logger interface { 44 Infof(string, ...interface{}) 45 Debugf(string, ...interface{}) 46 Warningf(string, ...interface{}) 47 Errorf(string, ...interface{}) 48 }