From 41fba617290beee30f4948425e7cf83d3c343505 Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Thu, 9 Nov 2023 14:34:08 +0100 Subject: [PATCH 1/2] Print panic output on Error log level --- client.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index cd89985a..fc866747 100644 --- a/client.go +++ b/client.go @@ -1085,6 +1085,8 @@ func (c *Client) logStderr(name string, r io.Reader) { reader := bufio.NewReaderSize(r, stdErrBufferSize) // continuation indicates the previous line was a prefix continuation := false + // continuation indicates the previous line was a panic output + panic := false for { line, isPrefix, err := reader.ReadLine() @@ -1121,19 +1123,32 @@ func (c *Client) logStderr(name string, r io.Reader) { // string prefixes switch line := string(line); { case strings.HasPrefix(line, "[TRACE]"): + panic = false l.Trace(line) case strings.HasPrefix(line, "[DEBUG]"): + panic = false l.Debug(line) case strings.HasPrefix(line, "[INFO]"): + panic = false l.Info(line) case strings.HasPrefix(line, "[WARN]"): + panic = false l.Warn(line) case strings.HasPrefix(line, "[ERROR]"): + panic = false + l.Error(line) + case strings.HasPrefix(line, "panic:"): + panic = true l.Error(line) default: - l.Debug(line) + if panic { + l.Error(line) + } else { + l.Debug(line) + } } } else { + panic = false out := flattenKVPairs(entry.KVPairs) out = append(out, "timestamp", entry.Timestamp.Format(hclog.TimeFormat)) From 4cdb5c7aab03043edbf1248d6b6fe2d6178a8d62 Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Thu, 17 Oct 2024 12:42:54 +0200 Subject: [PATCH 2/2] Update client.go Co-authored-by: Robert <17119716+robmonte@users.noreply.github.com> --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index fc866747..6cf3a1f2 100644 --- a/client.go +++ b/client.go @@ -1085,7 +1085,7 @@ func (c *Client) logStderr(name string, r io.Reader) { reader := bufio.NewReaderSize(r, stdErrBufferSize) // continuation indicates the previous line was a prefix continuation := false - // continuation indicates the previous line was a panic output + // panic indicates the previous line was the start of a panic output panic := false for {