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

Remove log.Printf from SDK's code #394

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo(
path = strings.Replace(path, "{{ "{" }}{{ pp.paramName }}{{ "}" }}", {% if pp.isInteger or pp.isLong %}strconv.FormatInt({{ pp.paramName }}, 10){% else %}{{ pp.paramName }}{% endif %}, -1)
{% endfor %}
{% if op.bodyParam != null and op.bodyParam.isFile %}
log.Printf("Sending request: method={{ op.httpMethod }} path=%s bodyContentType=%s\n", path, {{ op.bodyParam.paramName }}ContentType)
req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), {{ op.bodyParam.paramName }}Reader)
if err != nil {
return nil, {{ nilval }}, err
Expand All @@ -207,7 +206,6 @@ func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo(
if err := enc.Encode({{ op.bodyParam.paramName }}); err != nil {
return nil, {{ nilval }}, err
}
log.Printf("Sending request: method={{ op.httpMethod }} path=%s body=%s\n", path, buf.String())
req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), &buf)
if err != nil {
return nil, {{ nilval }}, err
Expand All @@ -232,7 +230,6 @@ func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo(
return nil, {{ nilval }}, err
}

log.Printf("Sending request: method={{ op.httpMethod }} path=%s\n", path)
req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), body)
if err != nil {
return nil, {{ nilval }}, err
Expand All @@ -247,14 +244,12 @@ func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo(
buf := vs.Encode()
body := bytes.NewBufferString(buf)

log.Printf("Sending request: method={{ op.httpMethod }} path=%s body=%s\n", path, buf)
req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), body)
if err != nil {
return nil, {{ nilval }}, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
{% else %}
log.Printf("Sending request: method={{ op.httpMethod }} path=%s\n", path)
req, err := http.NewRequest(http.Method{{ op.httpMethod }}, client.Url(path), nil)
if err != nil {
return nil, {{ nilval }}, err
Expand All @@ -274,7 +269,6 @@ func (client *{{ classname }}) {{ op.operationId }}WithHttpInfo(
{% endif %}

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, {{ nilval }}, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,5 @@ func Test{{ op.operationId }}(t *testing.T) {
if err != nil {
t.Fatalf("Failed to call API: %v", err)
}
log.Printf("Got response: %v", resp)
}
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func Unmarshal{{ model.classname }}(data []byte) ({{ model.classname }}Interface
return {{ mm.mappingName }}, nil
{% endfor %}
default:
log.Println("{{ model.classname }} fallback: ", discriminator)
var unknown Unknown{{ model.classname }}
unknown.{{ model.discriminator.propertyName }} = discriminator
unknown.Raw = raw
Expand Down
17 changes: 0 additions & 17 deletions linebot/channel_access_token/api_channel_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -146,7 +145,6 @@ func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIdsWithHtt
) (*http.Response, *ChannelAccessTokenKeyIdsResponse, error) {
path := "/oauth2/v2.1/tokens/kid"

log.Printf("Sending request: method=Get path=%s\n", path)
req, err := http.NewRequest(http.MethodGet, client.Url(path), nil)
if err != nil {
return nil, nil, err
Expand All @@ -159,7 +157,6 @@ func (client *ChannelAccessTokenAPI) GetsAllValidChannelAccessTokenKeyIdsWithHtt
req.URL.RawQuery = query.Encode()

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -244,15 +241,13 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenWithHttpInfo(
buf := vs.Encode()
body := bytes.NewBufferString(buf)

log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf)
req, err := http.NewRequest(http.MethodPost, client.Url(path), body)
if err != nil {
return nil, nil, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -337,15 +332,13 @@ func (client *ChannelAccessTokenAPI) IssueChannelTokenByJWTWithHttpInfo(
buf := vs.Encode()
body := bytes.NewBufferString(buf)

log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf)
req, err := http.NewRequest(http.MethodPost, client.Url(path), body)
if err != nil {
return nil, nil, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -448,15 +441,13 @@ func (client *ChannelAccessTokenAPI) IssueStatelessChannelTokenWithHttpInfo(
buf := vs.Encode()
body := bytes.NewBufferString(buf)

log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf)
req, err := http.NewRequest(http.MethodPost, client.Url(path), body)
if err != nil {
return nil, nil, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -523,15 +514,13 @@ func (client *ChannelAccessTokenAPI) RevokeChannelTokenWithHttpInfo(
buf := vs.Encode()
body := bytes.NewBufferString(buf)

log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf)
req, err := http.NewRequest(http.MethodPost, client.Url(path), body)
if err != nil {
return nil, struct{}{}, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, struct{}{}, err
Expand Down Expand Up @@ -611,15 +600,13 @@ func (client *ChannelAccessTokenAPI) RevokeChannelTokenByJWTWithHttpInfo(
buf := vs.Encode()
body := bytes.NewBufferString(buf)

log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf)
req, err := http.NewRequest(http.MethodPost, client.Url(path), body)
if err != nil {
return nil, struct{}{}, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, struct{}{}, err
Expand Down Expand Up @@ -681,15 +668,13 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenWithHttpInfo(
buf := vs.Encode()
body := bytes.NewBufferString(buf)

log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf)
req, err := http.NewRequest(http.MethodPost, client.Url(path), body)
if err != nil {
return nil, nil, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -750,7 +735,6 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWTWithHttpInfo(
) (*http.Response, *VerifyChannelAccessTokenResponse, error) {
path := "/oauth2/v2.1/verify"

log.Printf("Sending request: method=Get path=%s\n", path)
req, err := http.NewRequest(http.MethodGet, client.Url(path), nil)
if err != nil {
return nil, nil, err
Expand All @@ -762,7 +746,6 @@ func (client *ChannelAccessTokenAPI) VerifyChannelTokenByJWTWithHttpInfo(
req.URL.RawQuery = query.Encode()

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down
11 changes: 0 additions & 11 deletions linebot/insight/api_insight.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -135,14 +134,12 @@ func (client *InsightAPI) GetFriendsDemographics() (*GetFriendsDemographicsRespo
func (client *InsightAPI) GetFriendsDemographicsWithHttpInfo() (*http.Response, *GetFriendsDemographicsResponse, error) {
path := "/v2/bot/insight/demographic"

log.Printf("Sending request: method=Get path=%s\n", path)
req, err := http.NewRequest(http.MethodGet, client.Url(path), nil)
if err != nil {
return nil, nil, err
}

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -203,7 +200,6 @@ func (client *InsightAPI) GetMessageEventWithHttpInfo(
) (*http.Response, *GetMessageEventResponse, error) {
path := "/v2/bot/insight/message/event"

log.Printf("Sending request: method=Get path=%s\n", path)
req, err := http.NewRequest(http.MethodGet, client.Url(path), nil)
if err != nil {
return nil, nil, err
Expand All @@ -215,7 +211,6 @@ func (client *InsightAPI) GetMessageEventWithHttpInfo(
req.URL.RawQuery = query.Encode()

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -276,7 +271,6 @@ func (client *InsightAPI) GetNumberOfFollowersWithHttpInfo(
) (*http.Response, *GetNumberOfFollowersResponse, error) {
path := "/v2/bot/insight/followers"

log.Printf("Sending request: method=Get path=%s\n", path)
req, err := http.NewRequest(http.MethodGet, client.Url(path), nil)
if err != nil {
return nil, nil, err
Expand All @@ -288,7 +282,6 @@ func (client *InsightAPI) GetNumberOfFollowersWithHttpInfo(
req.URL.RawQuery = query.Encode()

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -349,7 +342,6 @@ func (client *InsightAPI) GetNumberOfMessageDeliveriesWithHttpInfo(
) (*http.Response, *GetNumberOfMessageDeliveriesResponse, error) {
path := "/v2/bot/insight/message/delivery"

log.Printf("Sending request: method=Get path=%s\n", path)
req, err := http.NewRequest(http.MethodGet, client.Url(path), nil)
if err != nil {
return nil, nil, err
Expand All @@ -361,7 +353,6 @@ func (client *InsightAPI) GetNumberOfMessageDeliveriesWithHttpInfo(
req.URL.RawQuery = query.Encode()

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -438,7 +429,6 @@ func (client *InsightAPI) GetStatisticsPerUnitWithHttpInfo(
) (*http.Response, *GetStatisticsPerUnitResponse, error) {
path := "/v2/bot/insight/message/event/aggregation"

log.Printf("Sending request: method=Get path=%s\n", path)
req, err := http.NewRequest(http.MethodGet, client.Url(path), nil)
if err != nil {
return nil, nil, err
Expand All @@ -452,7 +442,6 @@ func (client *InsightAPI) GetStatisticsPerUnitWithHttpInfo(
req.URL.RawQuery = query.Encode()

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down
9 changes: 0 additions & 9 deletions linebot/liff/api_liff.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -154,15 +153,13 @@ func (client *LiffAPI) AddLIFFAppWithHttpInfo(
if err := enc.Encode(addLiffAppRequest); err != nil {
return nil, nil, err
}
log.Printf("Sending request: method=Post path=%s body=%s\n", path, buf.String())
req, err := http.NewRequest(http.MethodPost, client.Url(path), &buf)
if err != nil {
return nil, nil, err
}
req.Header.Set("Content-Type", "application/json; charset=UTF-8")

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -225,14 +222,12 @@ func (client *LiffAPI) DeleteLIFFAppWithHttpInfo(

path = strings.Replace(path, "{liffId}", liffId, -1)

log.Printf("Sending request: method=Delete path=%s\n", path)
req, err := http.NewRequest(http.MethodDelete, client.Url(path), nil)
if err != nil {
return nil, struct{}{}, err
}

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, struct{}{}, err
Expand Down Expand Up @@ -275,14 +270,12 @@ func (client *LiffAPI) GetAllLIFFApps() (*GetAllLiffAppsResponse, error) {
func (client *LiffAPI) GetAllLIFFAppsWithHttpInfo() (*http.Response, *GetAllLiffAppsResponse, error) {
path := "/liff/v1/apps"

log.Printf("Sending request: method=Get path=%s\n", path)
req, err := http.NewRequest(http.MethodGet, client.Url(path), nil)
if err != nil {
return nil, nil, err
}

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, nil, err
Expand Down Expand Up @@ -358,15 +351,13 @@ func (client *LiffAPI) UpdateLIFFAppWithHttpInfo(
if err := enc.Encode(updateLiffAppRequest); err != nil {
return nil, struct{}{}, err
}
log.Printf("Sending request: method=Put path=%s body=%s\n", path, buf.String())
req, err := http.NewRequest(http.MethodPut, client.Url(path), &buf)
if err != nil {
return nil, struct{}{}, err
}
req.Header.Set("Content-Type", "application/json; charset=UTF-8")

res, err := client.Do(req)
log.Printf("Got response from '%s %s': status=%d, contentLength=%d", req.Method, req.URL, res.StatusCode, res.ContentLength)

if err != nil {
return res, struct{}{}, err
Expand Down
Loading