Skip to content

Commit

Permalink
chore: tweak log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jun 8, 2023
1 parent 52925fd commit 6f4b233
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions leetcode/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (c *cnClient) send(req *http.Request, authType authType, result any, failur
case withoutAuth:
case withAuth:
if err := c.opt.cred.AddCredentials(req); err != nil {
log.Warn("add credentials failed", "err", err)
log.Warn("add credentials failed, continue requesting without credentials", "err", err)
}
case requireAuth:
if err := c.opt.cred.AddCredentials(req); err != nil {
Expand Down Expand Up @@ -546,7 +546,7 @@ func (c *cnClient) GetTodayQuestion() (*QuestionData, error) {
graphqlRequest{
query: query,
operationName: "questionOfToday",
authType: withAuth,
authType: withoutAuth,
}, &resp, nil,
)
if err != nil {
Expand Down Expand Up @@ -575,7 +575,7 @@ func (c *cnClient) GetQuestionOfDate(date time.Time) (*QuestionData, error) {
"year": date.Year(),
"month": int(date.Month()),
},
authType: withAuth,
authType: withoutAuth,
},
&resp, nil,
)
Expand Down
2 changes: 1 addition & 1 deletion leetcode/client_us.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (c *usClient) GetTodayQuestion() (*QuestionData, error) {
}`
var resp gjson.Result
_, err := c.graphqlPost(
graphqlRequest{query: query, authType: withAuth}, &resp, nil,
graphqlRequest{query: query, authType: withoutAuth}, &resp, nil,
)
if err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions leetcode/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (p *passwordAuth) AddCredentials(req *http.Request) error {
}
}
if !p.hasAuth() {
return errors.New("no credential found")
return errors.New("login failed")
}
}
return p.cookiesAuth.AddCredentials(req)
Expand Down Expand Up @@ -143,7 +143,6 @@ func (b *browserAuth) AddCredentials(req *http.Request) error {
if !b.hasAuth() {
u, _ := url.Parse(b.c.BaseURI())
domain := u.Host
log.Info("reading cookies from browsers", "domain", domain)

defer func(start time.Time) {
log.Debug("finished reading cookies", "elapsed", time.Since(start))
Expand Down Expand Up @@ -185,7 +184,7 @@ func (b *browserAuth) AddCredentials(req *http.Request) error {
}
b.LeetCodeSession = session
b.CsrfToken = csrfToken
log.Debug("found cookie", "browser", store.Browser())
log.Info("found cookies", "browser", store.Browser(), "domain", domain)
break
}
}
Expand Down

0 comments on commit 6f4b233

Please sign in to comment.