github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/logger/adapter.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package logger 5 6 // Loggerf is a minimal log interface (using proper formatter style methods) 7 type Loggerf interface { 8 Debugf(s string, args ...interface{}) 9 Infof(s string, args ...interface{}) 10 Warningf(s string, args ...interface{}) 11 Errorf(s string, args ...interface{}) 12 } 13 14 type loggerInternal interface { 15 Debug(s string, args ...interface{}) 16 Info(s string, args ...interface{}) 17 Warning(s string, args ...interface{}) 18 Errorf(s string, args ...interface{}) 19 } 20 21 type logf struct { 22 log loggerInternal 23 } 24 25 // NewLoggerf adapts a logger 26 func NewLoggerf(log loggerInternal) Loggerf { 27 return logf{log: log} 28 } 29 30 // Debugf forwards to Logger.Debug 31 func (l logf) Debugf(s string, args ...interface{}) { 32 l.log.Debug(s, args...) 33 } 34 35 // Infof forwards to Logger.Info 36 func (l logf) Infof(s string, args ...interface{}) { 37 l.log.Info(s, args...) 38 } 39 40 // Warningf forwards to Logger.Warning 41 func (l logf) Warningf(s string, args ...interface{}) { 42 l.log.Warning(s, args...) 43 } 44 45 // Errorf forwards to Logger.Errorf 46 func (l logf) Errorf(s string, args ...interface{}) { 47 l.log.Errorf(s, args...) 48 }