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 30, 2024
1 parent beff557 commit ad60a54
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cmd/adder/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Blink Labs Software
// Copyright 2024 Blink Labs Software
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,10 +16,11 @@ package main

import (
"fmt"
"log/slog"
"net/http"
"os"

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

"github.com/blinklabs-io/adder/api"
_ "github.com/blinklabs-io/adder/filter"
Expand All @@ -36,6 +37,10 @@ const (
programName = "adder"
)

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

func main() {
cfg := config.GetConfig()

Expand Down Expand Up @@ -86,6 +91,15 @@ func main() {
// Configure logging
logging.Configure()
logger := logging.GetLogger()
slog.SetDefault(logger)

// 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
logger.Error(err.Error())
os.Exit(1)
}

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

0 comments on commit ad60a54

Please sign in to comment.