github.com/blend/go-sdk@v1.20220411.3/graceful/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 graceful 9 10 // Logger is a type that can be used as a graceful process logger. 11 type Logger interface { 12 Infof(format string, args ...interface{}) 13 Debugf(format string, args ...interface{}) 14 Errorf(format string, args ...interface{}) 15 } 16 17 // MaybeInfof calls the logger infof method if the logger is set. 18 func MaybeInfof(log Logger, format string, args ...interface{}) { 19 if log != nil { 20 log.Infof(format, args...) 21 } 22 } 23 24 // MaybeDebugf calls the logger debugf method if the logger is set. 25 func MaybeDebugf(log Logger, format string, args ...interface{}) { 26 if log != nil { 27 log.Debugf(format, args...) 28 } 29 } 30 31 // MaybeErrorf calls the logger errorf method if the logger is set. 32 func MaybeErrorf(log Logger, format string, args ...interface{}) { 33 if log != nil { 34 log.Errorf(format, args...) 35 } 36 }