Skip to content

Commit

Permalink
feat: log config when starting
Browse files Browse the repository at this point in the history
  • Loading branch information
2color committed Aug 19, 2024
1 parent 9664fad commit e2b9f09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package main

import (
"errors"
"fmt"
"log"
"os"
"strings"
"time"

"github.com/ipfs/boxo/ipns"
Expand Down Expand Up @@ -116,6 +118,13 @@ func main() {
maxFD: ctx.Int("libp2p-max-fd"),

Check warning on line 118 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L113-L118

Added lines #L113 - L118 were not covered by tests
}

fmt.Printf("Starting %s %s\n", name, version)

Check warning on line 121 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L121

Added line #L121 was not covered by tests

fmt.Printf("SOMEGUY_ACCELERATED_DHT = %t\n", cfg.acceleratedDHTClient)
printIfListConfigured("SOMEGUY_PROVIDER_ENDPOINTS = ", cfg.contentEndpoints)
printIfListConfigured("SOMEGUY_PEER_ENDPOINTS = ", cfg.peerEndpoints)
printIfListConfigured("SOMEGUY_IPNS_ENDPOINTS = ", cfg.ipnsEndpoints)

Check warning on line 126 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L123-L126

Added lines #L123 - L126 were not covered by tests

return start(ctx.Context, cfg)
},
},
Expand Down Expand Up @@ -214,3 +223,9 @@ func main() {
log.Fatal(err)
}
}

func printIfListConfigured(message string, list []string) {
if len(list) > 0 {
fmt.Printf(message+"%v\n", strings.Join(list, ", "))

Check warning on line 229 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L227-L229

Added lines #L227 - L229 were not covered by tests
}
}
4 changes: 1 addition & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func start(ctx context.Context, cfg *config) error {
return err
}

fmt.Printf("Someguy libp2p host listening on %v\n", h.Addrs())

Check warning on line 65 in server.go

View check run for this annotation

Codecov / codecov/patch

server.go#L65

Added line #L65 was not covered by tests
var dhtRouting routing.Routing
if cfg.acceleratedDHTClient {
wrappedDHT, err := newBundledDHT(ctx, h)
Expand Down Expand Up @@ -97,8 +98,6 @@ func start(ctx context.Context, cfg *config) error {
return err
}

fmt.Printf("Starting %s %s\n", name, version)

mdlw := middleware.New(middleware.Config{
Recorder: metrics.NewRecorder(metrics.Config{Prefix: "someguy"}),
})
Expand Down Expand Up @@ -141,7 +140,6 @@ func start(ctx context.Context, cfg *config) error {
var wg sync.WaitGroup
wg.Add(1)

fmt.Printf("Listening on %s\n", cfg.listenAddress)
fmt.Printf("Delegated Routing API on http://127.0.0.1:%s/routing/v1\n", port)

go func() {
Expand Down

0 comments on commit e2b9f09

Please sign in to comment.