heating-monitor/internal/utils/utils.go

21 lines
374 B
Go
Raw Normal View History

2024-11-28 13:52:58 +01:00
package utils
import (
"encoding/json"
"fmt"
)
func Debug(v interface{}, args ...string) {
// utils.Debug(variable)
debug, err := json.MarshalIndent(v, "", " ")
if err != nil {
fmt.Println("Error marshaling JSON:", err)
return
}
// Print a title if there is one
if len(args) > 0 {
fmt.Printf("%s\n", args[0])
}
fmt.Printf("DEBUG:\n%s\n", string(debug))
}