Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print panic output on Error log level #292

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
hanzei marked this conversation as resolved.
Show resolved Hide resolved
panic := false

for {
line, isPrefix, err := reader.ReadLine()
Expand Down Expand Up @@ -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))
Expand Down