chore: replace logrus with standard lib log/slog

This commit is contained in:
Christoph Haas
2025-03-02 08:51:13 +01:00
parent 5c51573874
commit 7473132932
30 changed files with 479 additions and 247 deletions

View File

@@ -2,6 +2,7 @@ package domain
import (
"fmt"
"log/slog"
"math"
"net"
"regexp"
@@ -9,8 +10,6 @@ import (
"strings"
"time"
"github.com/sirupsen/logrus"
"github.com/h44z/wg-portal/internal"
)
@@ -166,18 +165,22 @@ func (i *Interface) GetRoutingTable() int {
numberStr := strings.ReplaceAll(routingTableStr, "0x", "")
routingTable, err := strconv.ParseUint(numberStr, 16, 64)
if err != nil {
logrus.Errorf("invalid hex routing table %s: %v", routingTableStr, err)
slog.Error("failed to parse routing table number", "table", routingTableStr, "error", err)
return -1
}
if routingTable > math.MaxInt32 {
logrus.Errorf("invalid routing table %s, too big", routingTableStr)
slog.Error("routing table number too large", "table", routingTable, "max", math.MaxInt32)
return -1
}
return int(routingTable)
default:
routingTable, err := strconv.Atoi(routingTableStr)
if err != nil {
logrus.Errorf("invalid routing table %s: %v", routingTableStr, err)
slog.Error("failed to parse routing table number", "table", routingTableStr, "error", err)
return -1
}
if routingTable > math.MaxInt32 {
slog.Error("routing table number too large", "table", routingTable, "max", math.MaxInt32)
return -1
}
return routingTable