diff --git a/debug.go b/debug.go index 3451f80..59a7f3a 100644 --- a/debug.go +++ b/debug.go @@ -59,27 +59,24 @@ func debugLog(msg string, kvs ...any) { }() ctx := context.Background() - if len(kvs) == 0 { - logger.Log(ctx, slog.LevelDebug, msg) - return - } + var pcs [1]uintptr + runtime.Callers(2, pcs[:]) + rec := slog.NewRecord(time.Now().UTC(), slog.LevelDebug, msg, pcs[0]) - attrs := make([]slog.Attr, 0, len(kvs)/2) - for i := 0; i < len(kvs); i += 2 { - k, ok := kvs[i].(string) - if !ok { - k = fmt.Sprintf("%v", kvs[i]) + if len(kvs) > 0 { + attrs := make([]slog.Attr, 0, len(kvs)/2) + for i := 0; i < len(kvs); i += 2 { + k, ok := kvs[i].(string) + if !ok { + k = fmt.Sprintf("%v", kvs[i]) + } + attrs = append(attrs, slog.Any(k, kvs[i+1])) } - attrs = append(attrs, slog.Any(k, kvs[i+1])) + rec.AddAttrs(attrs...) } - var pcs [1]uintptr - runtime.Callers(1, pcs[:]) - rec := slog.NewRecord(time.Now(), slog.LevelDebug, msg, pcs[0]) - rec.AddAttrs(attrs...) + // TODO: what should we do if this call to logger.Handler().Handle() fails? _ = logger.Handler().Handle(ctx, rec) - - _ = attrs[len(kvs)] } func inK8S() bool { diff --git a/internal/server/server.go b/internal/server/server.go index 3900c82..b1d6b84 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -115,7 +115,7 @@ func runServer(opts ...serverOption) error { if err != nil { return fmt.Errorf("could not connect to the database: %w", err) } - debugLog("connected to the database", "connectionString", connStr) + debugLog("connected to the database", "addr", conf.dbAddr, "database", conf.dbName, "user", conf.dbUser) // spin up gRPC server grpcOpts := []grpc.ServerOption{ diff --git a/internal/server/web/js/data.js b/internal/server/web/js/data.js index 12d50a4..8978b93 100644 --- a/internal/server/web/js/data.js +++ b/internal/server/web/js/data.js @@ -8,7 +8,7 @@ const listModules = async () => { const getModuleVersions = (module) => { return fetch( - `${apiBase}/module-versions?module_name=${module}&version_option=all` + `${apiBase}/module-versions?module_name=${module}&version_option=all&include_prerelease=true` ) .then((resp) => resp.json()) .then((data) => {