Moving to scaleset client for the controller (#4390)

This commit is contained in:
Nikola Jokic
2026-03-13 14:36:41 +01:00
committed by GitHub
parent 1d9f626c53
commit f99c6eda0b
27 changed files with 2695 additions and 360 deletions
+40
View File
@@ -0,0 +1,40 @@
package logger
import (
"fmt"
"log/slog"
"os"
"strings"
)
// New creates new slog.Logger based on the format
func New(logLevel string, logFormat string) (*slog.Logger, error) {
var lvl slog.Level
switch strings.ToLower(logLevel) {
case "debug":
lvl = slog.LevelDebug
case "info":
lvl = slog.LevelInfo
case "warn":
lvl = slog.LevelWarn
case "error":
lvl = slog.LevelError
default:
return nil, fmt.Errorf("invalid log level: %s", logLevel)
}
switch logFormat {
case "json":
return slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
AddSource: true,
Level: lvl,
})), nil
case "text":
return slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
AddSource: true,
Level: lvl,
})), nil
default:
return nil, fmt.Errorf("invalid log format: %s", logFormat)
}
}