Comments (4)
+1 for this feature, especially for the kubernetes ecosystem
from resty.
@thapabishwa-plerionaut @halfcrazy Thanks for reaching out. I'm sorry for the delayed response.
Resty provides a Logger
interface for user choice of overriding.
Lines 31 to 35 in 97187c4
So you could assign your existing logger instance to it.
client := resty.New().SetLogger(...)
from resty.
The interface you mentioned doesn't have the ability to interoperate with loggers(like gologr, klog, slog etc) that are used in kubernetes ecosystem.
package main
import (
"net/http"
"github.com/go-resty/resty/v2"
"sigs.k8s.io/controller-runtime/pkg/log"
)
func main() {
logger := log.Log.WithName("controller").WithName("mylogger")
/// cannot use logger (variable of type logr.Logger) as resty.Logger value in argument to resty.New().SetLogger: logr.Logger does not implement resty.Logger (missing method Debugf)
client := resty.New().SetLogger(logger)
cookies := []*http.Cookie{
&http.Cookie{
Name: "go-resty-1",
Value: "This is cookie 1 value",
},
&http.Cookie{
Name: "go-resty-2",
Value: "This is cookie 2 value",
},
}
client.SetCookies(cookies)
}
from resty.
logr.Logger does not implement resty.Logger (missing method Debugf)
@thapabishwa Based on the error message, it seems logr does not have a Debugf implementation. I suggest creating a tiny wrapper for the log library you would like to use.
For example, refer to -
Lines 37 to 66 in 94e70d3
from resty.
Related Issues (20)
- CVE-2023-45286 HOT 3
- Breaks application from Ctrl-C handling HOT 1
- Brotli support HOT 1
- How to handle response if a call to API returns 200 with struct A, or 201 with struct B? HOT 3
- SetResult failed with httpmock HOT 2
- CVE-2023-45286: HTTP request body disclosure HOT 3
- SetProxy HOT 3
- The request with SetFileReader retry time great than 1 will has issues HOT 1
- Signing requests with path parameters HOT 1
- Clone or copy of existing client HOT 6
- cache middleware HOT 4
- retrying of non-idempotent methods HOT 2
- Path param encoding is broken
- can't use image.decode on rawbody HOT 1
- Can it support socket5 proxy? HOT 2
- Resty retry function does not work in Slack as custom http client HOT 1
- Middleware around resty.Request.Execute including retries HOT 1
- about proxy
- Client: Improve its creation flow and its options
- Request: Improve Request struct and its usage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resty.