Initial code commit
This commit is contained in:
48
pkg/utils/debug_log.go
Normal file
48
pkg/utils/debug_log.go
Normal file
@@ -0,0 +1,48 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user