Fix logging for query creation on error (#132)

This commit is contained in:
Zach Wasserman 2020-12-15 02:45:03 +00:00 committed by GitHub
parent c1cc0e45f6
commit 55a2aa2c95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,6 +95,15 @@ func (mw loggingMiddleware) NewQuery(ctx context.Context, p kolide.QueryPayload)
loggedInUser = vc.Username()
}
defer func(begin time.Time) {
if query == nil {
_ = mw.loggerInfo(err).Log(
"method", "NewQuery",
"err", err,
"user", loggedInUser,
"took", time.Since(begin),
)
return
}
_ = mw.loggerInfo(err).Log(
"method", "NewQuery",
"err", err,