MCPcopy Create free account
hub / github.com/docker/model-test / writeLogEntry

Method writeLogEntry

services/request_logger.go:100–117  ·  view source on GitHub ↗

writeLogEntry writes a log entry to the file

(entry LogEntry)

Source from the content-addressed store, hash-verified

98
99// writeLogEntry writes a log entry to the file
100func (rl *RequestLogger) writeLogEntry(entry LogEntry) error {
101 jsonData, err := json.Marshal(entry)
102 if err != nil {
103 return fmt.Errorf("failed to marshal log entry: %w", err)
104 }
105
106 // Write JSON entry followed by newline
107 if _, err := rl.logFile.Write(jsonData); err != nil {
108 return fmt.Errorf("failed to write log entry: %w", err)
109 }
110
111 if _, err := rl.logFile.WriteString("\n"); err != nil {
112 return fmt.Errorf("failed to write newline: %w", err)
113 }
114
115 // Flush to ensure data is written immediately
116 return rl.logFile.Sync()
117}
118
119// Close closes the log file
120func (rl *RequestLogger) Close() error {

Callers 2

LogRequestMethod · 0.95
LogErrorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected