feat: introduce logger to config
All checks were successful
CI / test (pull_request) Successful in 37s
All checks were successful
CI / test (pull_request) Successful in 37s
This commit is contained in:
15
main.go
15
main.go
@@ -2,6 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"realdnydns/pkg/config"
|
||||
"realdnydns/pkg/dnsProvider"
|
||||
@@ -15,12 +18,24 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: slog.LevelInfo,
|
||||
}))
|
||||
|
||||
configClient := config.Config{}
|
||||
err := configClient.Load("config.yaml")
|
||||
if err != nil {
|
||||
logger.Error("Failed to load config file",
|
||||
slog.String("error", err.Error()))
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if configClient.LogLevel != "" {
|
||||
logger = slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: slog.Level(config.LogLevelMap[strings.ToLower(configClient.LogLevel)]),
|
||||
}))
|
||||
}
|
||||
|
||||
var externalIpProvider externalIpProvider.ExternalIpProvider
|
||||
switch configClient.ExternalIPProvider.Type {
|
||||
case "plain":
|
||||
|
||||
Reference in New Issue
Block a user