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 <wolf31o2@blinklabs.io>
  • Loading branch information
wolf31o2 committed Oct 4, 2024
1 parent eb6f420 commit 769c941
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/tx-submit-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
_ "net/http/pprof"
"os"

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

"github.com/blinklabs-io/tx-submit-api/internal/api"
"github.com/blinklabs-io/tx-submit-api/internal/config"
Expand All @@ -33,6 +33,10 @@ var cmdlineFlags struct {
configFile string
}

func logPrintf(format string, v ...any) {
logging.GetLogger().Infof(format, v...)
}

func main() {
flag.StringVar(
&cmdlineFlags.configFile,
Expand Down Expand Up @@ -63,6 +67,14 @@ func main() {

logger.Infof("starting tx-submit-api %s", version.GetVersionString())

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

// Start debug listener
if cfg.Debug.ListenPort > 0 {
logger.Infof(
Expand Down

0 comments on commit 769c941

Please sign in to comment.