Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass logger to automaxprocs #242

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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