Skip to content

Commit 6d414ad

Browse files
authored
feat: pass logger to automaxprocs (#143)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent f2e2aaa commit 6d414ad

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cmd/tx-submit-api-mirror/main.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"fmt"
2020
"os"
2121

22-
_ "go.uber.org/automaxprocs"
22+
"go.uber.org/automaxprocs/maxprocs"
2323

2424
"github.com/blinklabs-io/tx-submit-api-mirror/api"
2525
"github.com/blinklabs-io/tx-submit-api-mirror/config"
@@ -30,6 +30,10 @@ var cmdlineFlags struct {
3030
configFile string
3131
}
3232

33+
func logPrintf(format string, v ...any) {
34+
logging.GetLogger().Infof(format, v...)
35+
}
36+
3337
func main() {
3438
flag.StringVar(
3539
&cmdlineFlags.configFile,
@@ -58,6 +62,14 @@ func main() {
5862
}
5963
}()
6064

65+
// Configure max processes with our logger wrapper, toss undo func
66+
_, err = maxprocs.Set(maxprocs.Logger(logPrintf))
67+
if err != nil {
68+
// If we hit this, something really wrong happened
69+
logger.Errorf(err.Error())
70+
os.Exit(1)
71+
}
72+
6173
// Start API listener
6274
logger.Infof(
6375
"starting API listener on %s:%d",

0 commit comments

Comments
 (0)