mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-05-13 07:05:42 +08:00
style(cursor): replace fmt.Print* with log package for consistent logging
Address Gemini Code Assist review feedback: use logrus log package instead of fmt.Printf/Println in Cursor auth handlers and CLI for unified log formatting and level control. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3705,7 +3705,7 @@ func (h *Handler) RequestCursorToken(c *gin.Context) {
|
||||
ctx = PopulateAuthContext(ctx, c)
|
||||
|
||||
label := strings.TrimSpace(c.Query("label"))
|
||||
fmt.Printf("Initializing Cursor authentication (label=%q)...\n", label)
|
||||
log.Infof("Initializing Cursor authentication (label=%q)...", label)
|
||||
|
||||
authParams, err := cursorauth.GenerateAuthParams()
|
||||
if err != nil {
|
||||
@@ -3718,13 +3718,13 @@ func (h *Handler) RequestCursorToken(c *gin.Context) {
|
||||
RegisterOAuthSession(state, "cursor")
|
||||
|
||||
go func() {
|
||||
fmt.Println("Waiting for Cursor authentication...")
|
||||
fmt.Printf("Open this URL in your browser: %s\n", authParams.LoginURL)
|
||||
log.Info("Waiting for Cursor authentication...")
|
||||
log.Infof("Open this URL in your browser: %s", authParams.LoginURL)
|
||||
|
||||
tokens, errPoll := cursorauth.PollForAuth(ctx, authParams.UUID, authParams.Verifier)
|
||||
if errPoll != nil {
|
||||
SetOAuthSessionError(state, "Authentication failed: "+errPoll.Error())
|
||||
fmt.Printf("Cursor authentication failed: %v\n", errPoll)
|
||||
log.Errorf("Cursor authentication failed: %v", errPoll)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3761,7 +3761,7 @@ func (h *Handler) RequestCursorToken(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Cursor authentication successful! Token saved to %s\n", savedPath)
|
||||
log.Infof("Cursor authentication successful! Token saved to %s", savedPath)
|
||||
CompleteOAuthSession(state)
|
||||
CompleteOAuthSessionsByProvider("cursor")
|
||||
}()
|
||||
|
||||
@@ -2,7 +2,6 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
||||
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
||||
@@ -29,10 +28,10 @@ func DoCursorLogin(cfg *config.Config, options *LoginOptions) {
|
||||
}
|
||||
|
||||
if savedPath != "" {
|
||||
fmt.Printf("Authentication saved to %s\n", savedPath)
|
||||
log.Infof("Authentication saved to %s", savedPath)
|
||||
}
|
||||
if record != nil && record.Label != "" {
|
||||
fmt.Printf("Authenticated as %s\n", record.Label)
|
||||
log.Infof("Authenticated as %s", record.Label)
|
||||
}
|
||||
fmt.Println("Cursor authentication successful!")
|
||||
log.Info("Cursor authentication successful!")
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ func (a CursorAuthenticator) Login(ctx context.Context, cfg *config.Config, opts
|
||||
}
|
||||
|
||||
// Display the login URL
|
||||
fmt.Println("Starting Cursor authentication...")
|
||||
fmt.Printf("\nPlease visit this URL to log in:\n%s\n\n", authParams.LoginURL)
|
||||
log.Info("Starting Cursor authentication...")
|
||||
log.Infof("Please visit this URL to log in: %s", authParams.LoginURL)
|
||||
|
||||
// Try to open the browser automatically
|
||||
if !opts.NoBrowser {
|
||||
@@ -59,7 +59,7 @@ func (a CursorAuthenticator) Login(ctx context.Context, cfg *config.Config, opts
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Waiting for Cursor authorization...")
|
||||
log.Info("Waiting for Cursor authorization...")
|
||||
|
||||
// Poll for the auth result
|
||||
tokens, err := cursorauth.PollForAuth(ctx, authParams.UUID, authParams.Verifier)
|
||||
@@ -69,7 +69,7 @@ func (a CursorAuthenticator) Login(ctx context.Context, cfg *config.Config, opts
|
||||
|
||||
expiresAt := cursorauth.GetTokenExpiry(tokens.AccessToken)
|
||||
|
||||
fmt.Println("\nCursor authentication successful!")
|
||||
log.Info("Cursor authentication successful!")
|
||||
|
||||
metadata := map[string]any{
|
||||
"type": "cursor",
|
||||
|
||||
Reference in New Issue
Block a user