Skip to content

Commit

Permalink
feat: pass logger to automaxprocs
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 committed Oct 6, 2024
1 parent 80659e7 commit 9861b30
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/bluefin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"log/slog"
"os"

_ "go.uber.org/automaxprocs"
"go.uber.org/automaxprocs/maxprocs"

"github.com/blinklabs-io/bluefin/internal/config"
"github.com/blinklabs-io/bluefin/internal/indexer"
Expand All @@ -34,6 +34,10 @@ var cmdlineFlags struct {
debug bool
}

func slogPrintf(format string, v ...any) {
slog.Info(fmt.Sprintf(format, v...))
}

func main() {
flag.StringVar(
&cmdlineFlags.configFile,
Expand Down Expand Up @@ -71,6 +75,15 @@ func main() {
slog.Info(
fmt.Sprintf("bluefin %s started", version.GetVersionString()),
)

// Configure max processes with our logger wrapper, toss undo func
_, err = maxprocs.Set(maxprocs.Logger(slogPrintf))
if err != nil {
// If we hit this, something really wrong happened
slog.Error(err.Error())
os.Exit(1)
}

// Load storage
if err := storage.GetStorage().Load(); err != nil {
slog.Error(
Expand Down

0 comments on commit 9861b30

Please sign in to comment.