diff --git a/migrations/kdvh/import/cache/kdvh.go b/migrations/kdvh/import/cache/kdvh.go index ea2d77a..0ca938c 100644 --- a/migrations/kdvh/import/cache/kdvh.go +++ b/migrations/kdvh/import/cache/kdvh.go @@ -35,7 +35,7 @@ type Timespan struct { func cacheKDVH(tables, stations, elements []string, kdvh *db.KDVH) KDVHMap { cache := make(KDVHMap) - fmt.Println("Connecting to KDVH proxy to cache metadata") + slog.Info("Connecting to KDVH proxy to cache metadata") ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() diff --git a/migrations/kdvh/import/cache/main.go b/migrations/kdvh/import/cache/main.go index 13d153f..ed877e6 100644 --- a/migrations/kdvh/import/cache/main.go +++ b/migrations/kdvh/import/cache/main.go @@ -27,7 +27,7 @@ type Cache struct { // Caches all the metadata needed for import of KDVH tables. // If any error occurs inside here the program will exit. func CacheMetadata(tables, stations, elements []string, kdvh *db.KDVH) *Cache { - fmt.Println("Connecting to Stinfosys to cache metadata") + slog.Info("Connecting to Stinfosys to cache metadata") ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() diff --git a/migrations/kdvh/import/main.go b/migrations/kdvh/import/main.go index 40b88a7..b1be220 100644 --- a/migrations/kdvh/import/main.go +++ b/migrations/kdvh/import/main.go @@ -3,6 +3,7 @@ package port import ( "context" "fmt" + "log" "log/slog" "os" "slices" @@ -33,6 +34,7 @@ func (config *Config) Execute([]string) error { os.Exit(1) } + slog.Info("Import started!") kdvh := db.Init() // Cache metadata from Stinfosys, KDVH, and local `product_offsets.csv` @@ -66,15 +68,17 @@ func (config *Config) Execute([]string) error { ImportTable(table, cache, pool, config) } + log.SetOutput(os.Stdout) if config.Reindex { createIndices(pool) } + slog.Info("Import complete!") return nil } func dropIndices(pool *pgxpool.Pool) { - fmt.Println("Dropping table indices...") + slog.Info("Dropping table indices...") file, err := os.ReadFile("../db/drop_indices.sql") if err != nil { @@ -88,7 +92,7 @@ func dropIndices(pool *pgxpool.Pool) { } func createIndices(pool *pgxpool.Pool) { - fmt.Println("Recreating table indices...") + slog.Info("Recreating table indices...") files := []string{"../db/public.sql", "../db/flags.sql"} for _, filename := range files {