github.com/blend/go-sdk@v1.20220411.3/r2/opt_log.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 r2 9 10 import ( 11 "github.com/blend/go-sdk/logger" 12 ) 13 14 // OptLog adds OnRequest and OnResponse listeners to log that a call was made. 15 func OptLog(log logger.Log) Option { 16 return func(r *Request) error { 17 if err := OptLogRequest(log)(r); err != nil { 18 return err 19 } 20 if err := OptLogResponse(log)(r); err != nil { 21 return err 22 } 23 return nil 24 } 25 } 26 27 // OptLogWithBody adds OnRequest and OnResponse listeners to log that a call was made. 28 // It will also display the body of the response. 29 func OptLogWithBody(log logger.Log) Option { 30 return func(r *Request) error { 31 if err := OptLogRequest(log)(r); err != nil { 32 return err 33 } 34 if err := OptLogResponseWithBody(log)(r); err != nil { 35 return err 36 } 37 return nil 38 } 39 }