infra: add logging wrapping

Resolves issues with gcp cloud logging quirks such as field names
This commit is contained in:
Arjun Patel
2026-05-27 15:49:27 -07:00
parent e804cee229
commit 563c91e7d5
30 changed files with 347 additions and 250 deletions
+10 -8
View File
@@ -5,15 +5,17 @@ import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"strings"
"time"
"github.com/flowy-live/llink/internal/utils/flog"
firebaseauth "firebase.google.com/go/v4/auth"
pbaero "github.com/flowy-live/llink/genproto/aero"
"github.com/flowy-live/llink/internal/utils"
"github.com/redis/go-redis/v9"
"go.jetify.com/typeid"
pbaero "github.com/flowy-live/llink/genproto/aero"
"github.com/flowy-live/llink/internal/utils"
)
const (
@@ -86,7 +88,7 @@ func (a *authServiceImpl) MintFirebaseCustomToken(ctx context.Context, humanId s
func (a *authServiceImpl) IsSystemAdmin(ctx context.Context, email string) bool {
formattedEmail, err := utils.NormalizeEmail(email)
if err != nil {
slog.Error("problem validating email", "error", err)
flog.Error("problem validating email", "error", err)
return false
}
@@ -110,7 +112,7 @@ func (a *authServiceImpl) RequestSignInCode(ctx context.Context, email string) e
err = a.redisClient.Set(ctx, formattedEmail, code, codeExpiry).Err()
if err != nil {
slog.Error("error setting code in redis", "error", err)
flog.Error("error setting code in redis", "error", err)
return fmt.Errorf("error storing sign-in code: %w", err)
}
@@ -129,7 +131,7 @@ func (a *authServiceImpl) RequestSignInCode(ctx context.Context, email string) e
return fmt.Errorf("an error occurred while sending the email: %w", err)
}
slog.Info("sent sign in code", "email", formattedEmail)
flog.Info("sent sign in code", "email", formattedEmail)
return nil
}
@@ -144,7 +146,7 @@ func (a *authServiceImpl) VerifySignInCode(ctx context.Context, email, code, hum
if errors.Is(err, redis.Nil) {
return "", ErrInvalidCode
}
slog.Error("error getting code from redis", "error", err)
flog.Error("error getting code from redis", "error", err)
return "", fmt.Errorf("error verifying code: %w", err)
}
@@ -153,7 +155,7 @@ func (a *authServiceImpl) VerifySignInCode(ctx context.Context, email, code, hum
}
if err := a.redisClient.Del(ctx, formattedEmail).Err(); err != nil {
slog.Error("error deleting code from redis", "error", err)
flog.Error("error deleting code from redis", "error", err)
}
token, err := a.createSession(ctx, formattedEmail, humanId)