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
+8 -7
View File
@@ -5,10 +5,11 @@ package main
import (
"context"
"log/slog"
"os"
"time"
"github.com/flowy-live/llink/internal/utils/flog"
"cloud.google.com/go/firestore"
"cloud.google.com/go/storage"
"google.golang.org/api/iterator"
@@ -27,7 +28,7 @@ func main() {
storageClient, err := storage.NewClient(ctx)
if err != nil {
slog.Error("failed to create GCS client", "error", err)
flog.Error("failed to create GCS client", "error", err)
os.Exit(1)
}
defer storageClient.Close()
@@ -40,7 +41,7 @@ func main() {
gcpProject := utils.MustGetEnv("GCP_PROJECT")
fs, err := firestore.NewClient(ctx, gcpProject)
if err != nil {
slog.Error("failed to create Firestore client", "error", err)
flog.Error("failed to create Firestore client", "error", err)
os.Exit(1)
}
defer fs.Close()
@@ -49,7 +50,7 @@ func main() {
stats, err := run(ctx, fs, depotSvc)
elapsed := time.Since(started)
slog.Info("transcode_backfill_summary",
flog.Info("transcode_backfill_summary",
"scanned", stats.scanned,
"media", stats.media,
"transcoded", stats.transcoded,
@@ -61,7 +62,7 @@ func main() {
)
if err != nil {
slog.Error("transcode backfill aborted", "error", err)
flog.Error("transcode backfill aborted", "error", err)
os.Exit(1)
}
if stats.failures > 0 {
@@ -116,7 +117,7 @@ func run(ctx context.Context, fs *firestore.Client, depotSvc depot.Service) (sta
switch {
case result.Err != nil:
s.failures++
slog.Error("transcode_backfill_failure",
flog.Error("transcode_backfill_failure",
"particleID", doc.Ref.ID,
"path", doc.Ref.Path,
"error", result.Err,
@@ -129,7 +130,7 @@ func run(ctx context.Context, fs *firestore.Client, depotSvc depot.Service) (sta
s.skippedNonMedia++
default:
s.transcoded++
slog.Info("transcode_backfill_progress",
flog.Info("transcode_backfill_progress",
"particleID", doc.Ref.ID,
"transcodedObjectID", result.TranscodedObjectID,
"outputMime", result.OutputMimeType,