feat(logging): introduce centralized logging with custom format and Gin integration

- Implemented a global logger with structured formatting for consistent log output.
- Added support for rotating log files using Lumberjack.
- Integrated new logging functionality with Gin HTTP server for unified log handling.
- Replaced direct `log.Info` calls with `fmt.Printf` in non-critical paths to simplify core functionality.
This commit is contained in:
Luis Pater
2025-09-26 00:54:52 +08:00
parent 72325f792c
commit cf734f7e7b
20 changed files with 209 additions and 148 deletions

View File

@@ -51,19 +51,19 @@ func (a *QwenAuthenticator) Login(ctx context.Context, cfg *config.Config, opts
authURL := deviceFlow.VerificationURIComplete
if !opts.NoBrowser {
log.Info("Opening browser for Qwen authentication")
fmt.Println("Opening browser for Qwen authentication")
if !browser.IsAvailable() {
log.Warn("No browser available; please open the URL manually")
log.Infof("Visit the following URL to continue authentication:\n%s", authURL)
fmt.Printf("Visit the following URL to continue authentication:\n%s\n", authURL)
} else if err = browser.OpenURL(authURL); err != nil {
log.Warnf("Failed to open browser automatically: %v", err)
log.Infof("Visit the following URL to continue authentication:\n%s", authURL)
fmt.Printf("Visit the following URL to continue authentication:\n%s\n", authURL)
}
} else {
log.Infof("Visit the following URL to continue authentication:\n%s", authURL)
fmt.Printf("Visit the following URL to continue authentication:\n%s\n", authURL)
}
log.Info("Waiting for Qwen authentication...")
fmt.Println("Waiting for Qwen authentication...")
tokenData, err := authSvc.PollForToken(deviceFlow.DeviceCode, deviceFlow.CodeVerifier)
if err != nil {
@@ -101,7 +101,7 @@ func (a *QwenAuthenticator) Login(ctx context.Context, cfg *config.Config, opts
"email": tokenStorage.Email,
}
log.Info("Qwen authentication successful")
fmt.Println("Qwen authentication successful")
return &TokenRecord{
Provider: a.Provider(),