Skip to content

Commit cff32af

Browse files
authored
feat: pass logger to automaxprocs (#242)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent eb6f420 commit cff32af

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cmd/tx-submit-api/main.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
_ "net/http/pprof"
2222
"os"
2323

24-
_ "go.uber.org/automaxprocs"
24+
"go.uber.org/automaxprocs/maxprocs"
2525

2626
"github.com/blinklabs-io/tx-submit-api/internal/api"
2727
"github.com/blinklabs-io/tx-submit-api/internal/config"
@@ -33,6 +33,10 @@ var cmdlineFlags struct {
3333
configFile string
3434
}
3535

36+
func logPrintf(format string, v ...any) {
37+
logging.GetLogger().Infof(format, v...)
38+
}
39+
3640
func main() {
3741
flag.StringVar(
3842
&cmdlineFlags.configFile,
@@ -63,6 +67,14 @@ func main() {
6367

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

70+
// Configure max processes with our logger wrapper, toss undo func
71+
_, err = maxprocs.Set(maxprocs.Logger(logPrintf))
72+
if err != nil {
73+
// If we hit this, something really wrong happened
74+
logger.Errorf(err.Error())
75+
os.Exit(1)
76+
}
77+
6678
// Start debug listener
6779
if cfg.Debug.ListenPort > 0 {
6880
logger.Infof(

0 commit comments

Comments
 (0)