feat: improved logging with zerolog

This commit is contained in:
Nicolas Meienberger
2025-08-10 00:08:00 +02:00
parent d0bf890386
commit 18654426fa
14 changed files with 148 additions and 58 deletions

View File

@@ -2,25 +2,28 @@ package driver
import (
"encoding/json"
"ironmount/internal/constants"
"ironmount/internal/core"
"ironmount/internal/db"
"log"
"net/http"
"os"
"path/filepath"
"github.com/rs/zerolog/log"
)
func Create(w http.ResponseWriter, r *http.Request) {
log.Printf("Received create request: %s", r.URL.Path)
var req struct {
Name string
Opts map[string]string `json:"Opts,omitempty"`
}
_ = json.NewDecoder(r.Body).Decode(&req)
volPath := filepath.Join(constants.VolumeRoot, req.Name)
cfg := core.LoadConfig()
volPath := filepath.Join(cfg.VolumeRoot, req.Name)
log.Info().Str("path", volPath).Msg("Creating volume directory")
if err := os.MkdirAll(volPath, 0755); err != nil {
log.Error().Err(err).Str("path", volPath).Msg("Failed to create volume directory")
_ = json.NewEncoder(w).Encode(map[string]string{"Err": err.Error()})
return
}