Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: Expose Resty's SetLogger(...) function in linodego.Client #395

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ type clientCacheEntry struct {
ExpiryOverride *time.Duration
}

type Request = resty.Request
type (
Request = resty.Request
Logger = resty.Logger
)

func init() {
// Wether or not we will enable Resty debugging output
Expand Down Expand Up @@ -121,6 +124,14 @@ func (c *Client) SetDebug(debug bool) *Client {
return c
}

// SetLogger allows the user to override the output
// logger for debug logs.
func (c *Client) SetLogger(logger Logger) *Client {
c.resty.SetLogger(logger)

return c
}

// OnBeforeRequest adds a handler to the request body to run before the request is sent
func (c *Client) OnBeforeRequest(m func(request *Request) error) {
c.resty.OnBeforeRequest(func(client *resty.Client, req *resty.Request) error {
Expand Down