feat: add config and structured logging

This commit is contained in:
Patryk Hegenberg 2025-03-19 21:58:39 +01:00
parent 902a8bb7d1
commit fe83dc1f33
9 changed files with 275 additions and 31 deletions

View file

@ -2,7 +2,8 @@ package os
import (
"fmt"
"log"
"jws/internal/logger"
"log/slog"
"os"
"os/exec"
"strings"
@ -15,6 +16,12 @@ type OS struct {
PackageManager string
}
var log *slog.Logger
func init() {
log = logger.GetChildLogger("os")
}
func GetLinuxDistribution() (*OS, error) {
_, err := os.Stat("/etc/os-release")
if os.IsNotExist(err) {
@ -49,7 +56,8 @@ func parseOsRelease(osRelease string) *OS {
}
err := result.getPackageManager()
if err != nil {
log.Fatal(err)
log.Error(err.Error())
os.Exit(1)
}
return &result
}