From 130fcda42d2870faee436016299669c2b287555b Mon Sep 17 00:00:00 2001 From: oscarintherocks Date: Fri, 14 Jun 2024 17:48:15 +0200 Subject: [PATCH] issue 5212 timeout added to trace and error logs using ts switch --- pkg/output/output.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/output/output.go b/pkg/output/output.go index 449b73a2d1..8044c0aed9 100644 --- a/pkg/output/output.go +++ b/pkg/output/output.go @@ -304,13 +304,14 @@ func (w *StandardWriter) Write(event *ResultEvent) error { // JSONLogRequest is a trace/error log request written to file type JSONLogRequest struct { - Template string `json:"template"` - Type string `json:"type"` - Input string `json:"input"` - Address string `json:"address"` - Error string `json:"error"` - Kind string `json:"kind,omitempty"` - Attrs interface{} `json:"attrs,omitempty"` + Template string `json:"template"` + Type string `json:"type"` + Input string `json:"input"` + Timestamp *time.Time `json:"timestamp,omitempty"` + Address string `json:"address"` + Error string `json:"error"` + Kind string `json:"kind,omitempty"` + Attrs interface{} `json:"attrs,omitempty"` } // Request writes a log the requests trace log @@ -323,6 +324,10 @@ func (w *StandardWriter) Request(templatePath, input, requestType string, reques Input: input, Type: requestType, } + if w.timestamp { + ts := time.Now() + request.Timestamp = &ts + } parsed, _ := urlutil.ParseAbsoluteURL(input, false) if parsed != nil { request.Address = parsed.Hostname()