mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: improved logging with zerolog
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user