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

@ -5,10 +5,14 @@ import (
"embed"
"encoding/json"
"fmt"
"jws/internal/config"
"jws/internal/dependency"
"jws/internal/gui"
"jws/internal/logger"
"jws/internal/project"
"log/slog"
"os"
"path/filepath"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
@ -26,6 +30,24 @@ var (
)
func main() {
config, err := config.LoadConfig()
if err != nil {
fmt.Printf("Error loading config: %v\n", err)
os.Exit(1)
}
logLevel := slog.LevelInfo
if config.LogLevel == "debug" {
logLevel = slog.LevelDebug
}
err = logger.Init(config.LogFilePath, logLevel)
if err != nil {
fmt.Printf("Error initializing logger: %v\n", err)
os.Exit(1)
}
logger.Logger.Info("Applikation started")
a := app.New()
mainWindow = a.NewWindow("JakartaEE & Spring Boot Starter")
mainWindow.Resize(fyne.NewSize(600, 600))
@ -62,7 +84,7 @@ func main() {
}
// Load additional projects from projects.json
pluginProjects, err := loadProjects("projects.json")
pluginProjects, err := loadProjects(filepath.Join(config.ProjectsPath, "projects.json"))
if err != nil {
dialog.ShowError(fmt.Errorf("error loading projects: %v", err), mainWindow)
return
@ -70,8 +92,9 @@ func main() {
projects = append(standartProjects, pluginProjects...)
// Initialize GUI package
// Initialize packages
gui.Init(mainWindow, dependencies, projects, projectsFS)
project.Init(projects, config)
// Check dependencies
dependency.CheckDependencies(dependencies)