From d827a9d6b70b7d3b106a8d6f5747529fcca6ad0f Mon Sep 17 00:00:00 2001 From: Zach Wasserman Date: Thu, 18 Mar 2021 16:06:06 -0700 Subject: [PATCH] Log all errors regardless of log level (#496) Modify the loggerDebug function to check whether the error is nil before choosing the log level. Fixes #473 --- server/service/logging.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/service/logging.go b/server/service/logging.go index 3092521089..f0f5ced8a6 100644 --- a/server/service/logging.go +++ b/server/service/logging.go @@ -1,9 +1,9 @@ package service import ( + "github.com/fleetdm/fleet/server/kolide" kitlog "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - "github.com/fleetdm/fleet/server/kolide" ) // logging middleware logs the service actions @@ -17,8 +17,11 @@ func NewLoggingService(svc kolide.Service, logger kitlog.Logger) kolide.Service return loggingMiddleware{Service: svc, logger: logger} } -// loggerDebug returns the debug level +// loggerDebug returns the the info level if there error is non-nil, otherwise defaulting to the debug level. func (mw loggingMiddleware) loggerDebug(err error) kitlog.Logger { + if err != nil { + return level.Info(mw.logger) + } return level.Debug(mw.logger) }