about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--import/main.go4
-rw-r--r--internal/server/server.go17
-rw-r--r--serve/main.go9
3 files changed, 15 insertions, 15 deletions
diff --git a/import/main.go b/import/main.go
index b8ae633..87f8e4d 100644
--- a/import/main.go
+++ b/import/main.go
@@ -20,7 +20,8 @@ import (
 const timeout = 30 * time.Minute
 
 type Config struct {
-	ConfigFile string `conf:"short:c"`
+	ConfigFile string     `conf:"short:c"`
+	LogLevel   slog.Level `conf:"default:INFO"`
 }
 
 func main() {
@@ -36,6 +37,7 @@ func main() {
 		}
 		log.Panicf("parsing runtime configuration: %v", err)
 	}
+	slog.SetLogLoggerLevel(runtimeConfig.LogLevel)
 
 	cfg, err := config.GetConfig(runtimeConfig.ConfigFile)
 	if err != nil {
diff --git a/internal/server/server.go b/internal/server/server.go
index f15d011..1611a7a 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -36,14 +36,15 @@ var (
 )
 
 type Config struct {
-	Production    bool    `conf:"default:false"`
-	InDevServer   bool    `conf:"default:false"`
-	LiveReload    bool    `conf:"default:false,flag:live"`
-	Root          string  `conf:"default:website"`
-	ListenAddress string  `conf:"default:localhost"`
-	Port          string  `conf:"default:3000,short:p"`
-	BaseURL       cfg.URL `conf:"default:http://localhost:3000,short:b"`
-	ConfigFile    string  `conf:"short:c"`
+	Production    bool       `conf:"default:false"`
+	InDevServer   bool       `conf:"default:false"`
+	LiveReload    bool       `conf:"default:false,flag:live"`
+	Root          string     `conf:"default:website"`
+	ListenAddress string     `conf:"default:localhost"`
+	Port          string     `conf:"default:3000,short:p"`
+	BaseURL       cfg.URL    `conf:"default:http://localhost:3000,short:b"`
+	ConfigFile    string     `conf:"short:c"`
+	LogLevel      slog.Level `conf:"default:INFO"`
 }
 
 type HTTPError struct {
diff --git a/serve/main.go b/serve/main.go
index 6b55977..9378de1 100644
--- a/serve/main.go
+++ b/serve/main.go
@@ -20,12 +20,6 @@ var (
 )
 
 func main() {
-	if os.Getenv("DEBUG") != "" {
-		slog.SetLogLoggerLevel(slog.LevelDebug)
-	}
-	log.SetFlags(log.LstdFlags | log.Lmsgprefix)
-	log.SetPrefix("searchix: ")
-
 	runtimeConfig := server.Config{}
 	help, err := conf.Parse("", &runtimeConfig)
 	if err != nil {
@@ -35,6 +29,9 @@ func main() {
 		}
 		log.Panicf("parsing runtime configuration: %v", err)
 	}
+	slog.SetLogLoggerLevel(runtimeConfig.LogLevel)
+	log.SetFlags(log.LstdFlags | log.Lmsgprefix)
+	log.SetPrefix("searchix: ")
 
 	c := make(chan os.Signal, 2)
 	signal.Notify(c, os.Interrupt)