Skip to content

Commit

Permalink
Merge pull request #282 from PDOK/logging
Browse files Browse the repository at this point in the history
chore: extra logging for defaults
  • Loading branch information
rkettelerij authored Feb 14, 2025
2 parents c51e9f5 + fc919a5 commit 5a3218e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package config
import (
"errors"
"fmt"
"log"
"os"

"github.com/creasty/defaults"
Expand Down Expand Up @@ -218,17 +219,21 @@ type License struct {

func setDefaults(config *Config) error {
// process 'default' tags
log.Println("Start setting defaults")
if err := defaults.Set(config); err != nil {
return fmt.Errorf("failed to set default configuration: %w", err)
}

// custom default logic
if len(config.AvailableLanguages) == 0 {
log.Println("Setting language defaults")
config.AvailableLanguages = append(config.AvailableLanguages, Language{language.Dutch}) // default to Dutch only
}
if config.OgcAPI.Tiles != nil {
log.Println("Setting tiles defaults")
config.OgcAPI.Tiles.Defaults()
}
log.Println("Done setting defaults")
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions config/ogcapi_tiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"fmt"
"log"
"slices"
"sort"

Expand All @@ -22,8 +23,10 @@ type OgcAPITiles struct {
func (o *OgcAPITiles) Defaults() {
if o.DatasetTiles != nil && o.DatasetTiles.HealthCheck.Srs == DefaultSrs &&
o.DatasetTiles.HealthCheck.TilePath == nil {
log.Println("Setting dataset tiles healthcheck")
o.DatasetTiles.deriveHealthCheckTilePath()
} else if o.Collections != nil {
log.Println("Setting collection tiles healthcheck")
for _, coll := range o.Collections {
if coll.Tiles.GeoDataTiles.HealthCheck.Srs == DefaultSrs && coll.Tiles.GeoDataTiles.HealthCheck.TilePath == nil {
coll.Tiles.GeoDataTiles.deriveHealthCheckTilePath()
Expand Down

0 comments on commit 5a3218e

Please sign in to comment.