-
Notifications
You must be signed in to change notification settings - Fork 45
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
json logger panics on write failures #38
Comments
Yes, the code should be removed such that if Encode() fails we move on silently. Go ahead and submit that PR. |
notnoop
pushed a commit
that referenced
this issue
Apr 23, 2019
Handle cases where json logging fails to write: * json serialization errors; log plain message with metadata with a field indicating that args are omitted from logs * io errors: ignore them, the same as non-json logging Panicing in either case is somewhat unexpected and lead to unexpected crashes, that can escalate a minor bad untested logging into an process crashes. Fixes #38
notnoop
pushed a commit
that referenced
this issue
Apr 23, 2019
Handle cases where json logging fails to write: * json serialization errors; log plain message with metadata with a field indicating that args are omitted from logs * io errors: ignore them, the same as non-json logging Panicing in either case is somewhat unexpected and lead to unexpected crashes, that can escalate a minor bad untested logging into an process crashes. Fixes #38
notnoop
pushed a commit
that referenced
this issue
Apr 23, 2019
Handle cases where json logging fails to write: * json serialization errors; log plain message with metadata with a field indicating that args are omitted from logs * io errors: ignore them, the same as non-json logging Panicing in either case is somewhat unexpected and lead to unexpected crashes, that can escalate a minor bad untested logging into an process crashes. Fixes #38
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The json logger unexpectedly panics when writing json format to writer backend fails:
go-hclog/intlogger.go
Lines 370 to 373 in 6907afb
go-hclog/intlogger.go
Lines 145 to 256 in 6907afb
We noticed it because json logger paniced when writing to Stderr, a closed pipe at the time. You can find more details in hashicorp/go-plugin#114 .
I'd suggest treating logging here as best-effort (like in the non-json case), or returning and propagating the error back to make it an application concern.
Also, I may suggest distinguishing between write failures (ignore these) and json marshaling failures (in which case, add a log line indicating a log line was dropped due to json incompatibility).
I'd be happy to submit a PR with the suggested changes if they seem reasonable to maintainers.
The text was updated successfully, but these errors were encountered: