Skip to content

Fix zero timestamp in stderr where upstream has time disabled #263

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
7 changes: 5 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,11 @@ func (c *Client) logStderr(r io.Reader) {
}
} else {
out := flattenKVPairs(entry.KVPairs)

out = append(out, "timestamp", entry.Timestamp.Format(hclog.TimeFormat))
if !entry.Timestamp.IsZero() {
// no point in including a zero timestamp
// this can happen if the upstream logger has DisableTime set to true
out = append(out, "timestamp", entry.Timestamp.Format(hclog.TimeFormat))
}
switch hclog.LevelFromString(entry.Level) {
case hclog.Trace:
l.Trace(entry.Message, out...)
Expand Down