mirror of
https://codeberg.org/scip/anydb.git
synced 2026-02-04 17:30:57 +01:00
replace the fiber framework with net/http.ServeMux
This commit is contained in:
@@ -19,11 +19,15 @@ 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"
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user