From 2093f10e12699c4358ba9b2b28095a8260e9e5fb Mon Sep 17 00:00:00 2001 From: Kevin Parsons Date: Tue, 7 May 2019 23:38:56 -0700 Subject: [PATCH] etwlogrus: Ignore error from ETW WriteEvent Signed-off-by: Kevin Parsons --- pkg/etwlogrus/hook.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/etwlogrus/hook.go b/pkg/etwlogrus/hook.go index e296727..4fce6cc 100644 --- a/pkg/etwlogrus/hook.go +++ b/pkg/etwlogrus/hook.go @@ -89,10 +89,17 @@ func (h *Hook) Fire(e *logrus.Entry) error { fields = append(fields, etw.SmartField(logrus.ErrorKey, e.Data[logrus.ErrorKey])) } - return h.provider.WriteEvent( + // Firing an ETW event is essentially best effort, as the event write can + // fail for reasons completely out of the control of the event writer (such + // as a session listening for the event having no available space in its + // buffers). Therefore, we don't return the error from WriteEvent, as it is + // just noise in many cases. + h.provider.WriteEvent( "LogrusEntry", etw.WithEventOpts(etw.WithLevel(level)), fields) + + return nil } // Close cleans up the hook and closes the ETW provider. If the provder was