Files
sslh-multiplex-lab/pkg/utils/debug_log.go
2026-01-29 00:03:02 +00:00

49 lines
1.2 KiB
Go

package utils
import (
"encoding/json"
"fmt"
"os"
"time"
)
const debugLogPath = "/Users/gmapple/Documents/Projects/labs/sslh-multiplex-lab/.cursor/debug.log"
type DebugLogEntry struct {
ID string `json:"id"`
Timestamp int64 `json:"timestamp"`
Location string `json:"location"`
Message string `json:"message"`
Data map[string]interface{} `json:"data"`
SessionID string `json:"sessionId"`
RunID string `json:"runId"`
HypothesisID string `json:"hypothesisId"`
}
func DebugLog(location, message string, data map[string]interface{}, hypothesisID string) {
entry := DebugLogEntry{
ID: fmt.Sprintf("log_%d", time.Now().UnixNano()),
Timestamp: time.Now().UnixMilli(),
Location: location,
Message: message,
Data: data,
SessionID: "debug-session",
RunID: "run1",
HypothesisID: hypothesisID,
}
jsonData, err := json.Marshal(entry)
if err != nil {
return
}
f, err := os.OpenFile(debugLogPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return
}
defer f.Close()
f.Write(jsonData)
f.WriteString("\n")
}