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 -6
View File
@@ -6,17 +6,19 @@ package main
import (
"context"
"log/slog"
"os"
"slices"
"time"
"github.com/flowy-live/llink/internal/utils/flog"
"cloud.google.com/go/firestore"
"google.golang.org/api/iterator"
"github.com/flowy-live/llink/internal/db"
"github.com/flowy-live/llink/internal/human"
"github.com/flowy-live/llink/internal/network"
"github.com/flowy-live/llink/internal/utils"
"google.golang.org/api/iterator"
)
func main() {
@@ -28,7 +30,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()
@@ -39,10 +41,10 @@ func main() {
started := time.Now()
written, scanned, err := reconcile(ctx, fs, humanSvc, networkSvc)
if err != nil {
slog.Error("reconciliation failed", "error", err, "elapsed", time.Since(started))
flog.Error("reconciliation failed", "error", err, "elapsed", time.Since(started))
os.Exit(1)
}
slog.Info("reconciliation complete",
flog.Info("reconciliation complete",
"humans_scanned", scanned,
"humans_written", written,
"elapsed", time.Since(started),
@@ -109,7 +111,7 @@ func snapshotMirror(ctx context.Context, fs *firestore.Client) (map[string][]str
Networks []string `firestore:"networks"`
}
if err := doc.DataTo(&data); err != nil {
slog.Warn("skipping malformed mirror doc", "id", doc.Ref.ID, "error", err)
flog.Warn("skipping malformed mirror doc", "id", doc.Ref.ID, "error", err)
continue
}
out[doc.Ref.ID] = data.Networks