[breaking-change] Remove the log-level config option.

This reverts commit 351d0a0c85.

This option does not have any effect at the moment and may potentially
confuse users. It can be easily reintroduced later (by reverting this
commit) once we start logging at any level other than `info`.
This commit is contained in:
miyuko
2025-12-07 13:09:24 +00:00
parent bc70cba215
commit 91f05e210e
3 changed files with 2 additions and 33 deletions

View File

@@ -2,7 +2,6 @@
# as the intrinsic default value.
log-format = "text"
log-level = "info"
[server]
# Use "-" to disable the handler.

View File

@@ -63,7 +63,6 @@ type Config struct {
Insecure bool `toml:"-" env:"insecure"`
Features []string `toml:"features"`
LogFormat string `toml:"log-format" default:"text"`
LogLevel string `toml:"log-level" default:"info"`
Server ServerConfig `toml:"server"`
Wildcard []WildcardConfig `toml:"wildcard"`
Fallback FallbackConfig `toml:"fallback"`

View File

@@ -13,7 +13,6 @@ import (
"os"
"runtime/debug"
"strconv"
"strings"
"sync"
"time"
@@ -62,29 +61,15 @@ func InitObservability() {
logHandlers := []slog.Handler{}
logLevel := slog.LevelInfo
switch strings.ToLower(config.LogLevel) {
case "debug":
logLevel = slog.LevelDebug
case "info":
logLevel = slog.LevelInfo
case "warn":
logLevel = slog.LevelWarn
case "error":
logLevel = slog.LevelError
default:
log.Println("unknown log level", config.LogLevel)
}
switch config.LogFormat {
case "none":
// nothing to do
case "text":
logHandlers = append(logHandlers,
slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: logLevel}))
slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{}))
case "json":
logHandlers = append(logHandlers,
slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{Level: logLevel}))
slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{}))
default:
log.Println("unknown log format", config.LogFormat)
}
@@ -93,7 +78,6 @@ func InitObservability() {
var err error
syslogHandler, err = syslog.NewHandler(&syslog.HandlerOptions{
Address: syslogAddr,
Level: logLevel,
AppName: "git-pages",
StructuredDataID: "git-pages",
})
@@ -154,7 +138,6 @@ func InitObservability() {
if enableLogs {
logHandlers = append(logHandlers, sentryslog.Option{
AddSource: true,
LogLevel: levelsFromMinimum(logLevel),
}.NewSentryHandler(context.Background()))
}
}
@@ -162,18 +145,6 @@ func InitObservability() {
slog.SetDefault(slog.New(slogmulti.Fanout(logHandlers...)))
}
// From sentryslog, because for some reason they don't make it public.
func levelsFromMinimum(minLevel slog.Level) []slog.Level {
allLevels := []slog.Level{slog.LevelDebug, slog.LevelInfo, slog.LevelWarn, slog.LevelError, sentryslog.LevelFatal}
var result []slog.Level
for _, level := range allLevels {
if level >= minLevel {
result = append(result, level)
}
}
return result
}
func FiniObservability() {
var wg sync.WaitGroup
timeout := 2 * time.Second