Replace fiber with net.http.ServeMux (#23)

This commit is contained in:
T. von Dein
2025-12-23 14:38:45 +01:00
parent 5a705b0af0
commit 3b37a67e02
10 changed files with 306 additions and 183 deletions

View File

@@ -19,14 +19,18 @@ package cfg
import (
"fmt"
"io"
"log/slog"
"os"
"runtime/debug"
"github.com/pelletier/go-toml"
"codeberg.org/scip/anydb/app"
"codeberg.org/scip/anydb/common"
"github.com/lmittmann/tint"
"github.com/pelletier/go-toml"
"github.com/tlinden/yadu"
)
var Version string = "v0.2.6"
var Version string = "v0.3.0"
type BucketConfig struct {
Encrypt bool
@@ -58,6 +62,8 @@ func (conf *Config) GetConfig(files []string) error {
}
}
conf.SetLogger()
return nil
}
@@ -114,3 +120,36 @@ func (conf *Config) ParseConfigFile(file string) error {
return nil
}
func (conf *Config) SetLogger() {
if conf.Debug {
buildInfo, _ := debug.ReadBuildInfo()
opts := &yadu.Options{
Level: slog.LevelDebug,
AddSource: true,
}
slog.SetLogLoggerLevel(slog.LevelDebug)
handler := yadu.NewHandler(os.Stdout, opts)
debuglogger := slog.New(handler).With(
slog.Group("program_info",
slog.Int("pid", os.Getpid()),
slog.String("go_version", buildInfo.GoVersion),
),
)
slog.SetDefault(debuglogger)
slog.Debug("parsed config", "conf", conf)
} else {
opts := &tint.Options{
Level: slog.LevelInfo,
AddSource: false,
}
handler := tint.NewHandler(os.Stderr, opts)
logger := slog.New(handler)
slog.SetDefault(logger)
}
}