From 46c2dd5b51f774a6bb3be67853c0e7dad19f7940 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Mon, 13 Jun 2022 15:16:45 +0200 Subject: [PATCH] make thumbnails service log less noisy --- changelog/unreleased/thumbnails-log.md | 6 ++++++ .../pkg/service/grpc/v0/decorators/logging.go | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/thumbnails-log.md diff --git a/changelog/unreleased/thumbnails-log.md b/changelog/unreleased/thumbnails-log.md new file mode 100644 index 0000000000..c02a24e301 --- /dev/null +++ b/changelog/unreleased/thumbnails-log.md @@ -0,0 +1,6 @@ +Enhancement: Make thumbnails service log less noisy + +Reduced the log severity when no thumbnail was found from warn to debug. +This reduces the spam in the logs. + +https://github.com/owncloud/ocis/pull/3959 diff --git a/extensions/thumbnails/pkg/service/grpc/v0/decorators/logging.go b/extensions/thumbnails/pkg/service/grpc/v0/decorators/logging.go index d37d827803..e8174d40ee 100644 --- a/extensions/thumbnails/pkg/service/grpc/v0/decorators/logging.go +++ b/extensions/thumbnails/pkg/service/grpc/v0/decorators/logging.go @@ -2,10 +2,12 @@ package decorators import ( "context" + "net/http" "time" "github.com/owncloud/ocis/v2/ocis-pkg/log" thumbnailssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/thumbnails/v0" + merrors "go-micro.dev/v4/errors" ) // NewLogging returns a service that logs messages. @@ -32,9 +34,17 @@ func (l logging) GetThumbnail(ctx context.Context, req *thumbnailssvc.GetThumbna Logger() if err != nil { - logger.Warn(). - Err(err). - Msg("Failed to execute") + merror := merrors.FromError(err) + switch merror.Code { + case http.StatusNotFound: + logger.Debug(). + Str("error_detail", merror.Detail). + Msg("no thumbnail found") + default: + logger.Warn(). + Err(err). + Msg("Failed to execute") + } } else { logger.Debug(). Msg("")