Skip to content

Commit

Permalink
Add a couple more log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Lun4m committed Nov 18, 2024
1 parent ea811bf commit e497c96
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion migrations/kdvh/import/cache/kdvh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion migrations/kdvh/import/cache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 6 additions & 2 deletions migrations/kdvh/import/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package port
import (
"context"
"fmt"
"log"
"log/slog"
"os"
"slices"
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit e497c96

Please sign in to comment.