From f02591b5c3187738938a9ff97afdb170a6a4bbdd Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Tue, 5 Jul 2022 08:41:21 +0200 Subject: [PATCH] improve startup error logging --- changelog/unreleased/fix-startup-error-logging.md | 7 +++++++ services/app-provider/pkg/command/server.go | 5 +++-- services/app-registry/pkg/command/server.go | 5 +++-- services/auth-basic/pkg/command/server.go | 5 +++-- services/auth-bearer/pkg/command/server.go | 5 +++-- services/auth-machine/pkg/command/server.go | 5 +++-- services/frontend/pkg/command/server.go | 5 +++-- services/gateway/pkg/command/server.go | 5 +++-- services/graph-explorer/pkg/command/server.go | 5 +++-- services/graph/pkg/command/server.go | 5 +++-- services/groups/pkg/command/server.go | 5 +++-- services/idp/pkg/command/server.go | 5 +++-- services/nats/pkg/command/server.go | 5 +++-- services/ocdav/pkg/command/server.go | 5 ++++- services/ocs/pkg/command/server.go | 7 ++++--- services/proxy/pkg/command/server.go | 5 +++-- services/search/pkg/command/server.go | 5 ++++- services/sharing/pkg/command/server.go | 5 +++-- services/storage-publiclink/pkg/command/server.go | 5 +++-- services/storage-shares/pkg/command/server.go | 5 +++-- services/storage-system/pkg/command/server.go | 5 +++-- services/storage-users/pkg/command/server.go | 5 +++-- services/store/pkg/command/server.go | 5 +++-- services/thumbnails/pkg/command/server.go | 6 +++++- services/users/pkg/command/server.go | 5 +++-- services/web/pkg/command/server.go | 2 +- services/webdav/pkg/command/server.go | 4 ++-- 27 files changed, 87 insertions(+), 49 deletions(-) create mode 100644 changelog/unreleased/fix-startup-error-logging.md diff --git a/changelog/unreleased/fix-startup-error-logging.md b/changelog/unreleased/fix-startup-error-logging.md new file mode 100644 index 00000000000..7bc7761bc68 --- /dev/null +++ b/changelog/unreleased/fix-startup-error-logging.md @@ -0,0 +1,7 @@ +Bugfix: Fix startup error logging + +We've fixed the startup error logging, so that users will the reason for a failed +startup even on "error" log level. Previously they would only see it on "info" log level. +Also in a lot of cases the reason for the failed shutdown was omitted. + +https://github.com/owncloud/ocis/pull/4093 diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index f6bdf87dc3e..72fe31104e8 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -53,9 +53,10 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). Str("server", cfg.Service.Name). + Err(err). Msg("Shutting down server") cancel() diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index 063a5986b80..f09619d595a 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -52,9 +52,10 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). Str("server", cfg.Service.Name). + Err(err). Msg("Shutting down server") cancel() diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index cb5bbf6b6c3..4e6a3b57421 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -66,9 +66,10 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). Str("server", cfg.Service.Name). + Err(err). Msg("Shutting down server") cancel() diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index 7a871f12c06..cfa598e5c07 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -53,9 +53,10 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). Str("server", cfg.Service.Name). + Err(err). Msg("Shutting down server") cancel() diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index 1bb1610f47a..7424c30200f 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -53,8 +53,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index f52e97ba8a3..20719e36ccc 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -53,8 +53,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/gateway/pkg/command/server.go b/services/gateway/pkg/command/server.go index 3287c92307a..adb9d6cf5cc 100644 --- a/services/gateway/pkg/command/server.go +++ b/services/gateway/pkg/command/server.go @@ -52,8 +52,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/graph-explorer/pkg/command/server.go b/services/graph-explorer/pkg/command/server.go index db484c4db8c..60586a267c2 100644 --- a/services/graph-explorer/pkg/command/server.go +++ b/services/graph-explorer/pkg/command/server.go @@ -75,9 +75,10 @@ func Server(cfg *config.Config) *cli.Command { Msg("Failed to start server") } return err - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). Str("transport", "http"). + Err(err). Msg("Shutting down server") cancel() diff --git a/services/graph/pkg/command/server.go b/services/graph/pkg/command/server.go index e0a1f0e7bb4..bdcccc2f385 100644 --- a/services/graph/pkg/command/server.go +++ b/services/graph/pkg/command/server.go @@ -66,9 +66,10 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). Str("transport", "http"). + Err(err). Msg("Shutting down server") cancel() diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index f90bef7c465..d1e872c4221 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -66,9 +66,10 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). Str("server", cfg.Service.Name). + Err(err). Msg("Shutting down server") cancel() diff --git a/services/idp/pkg/command/server.go b/services/idp/pkg/command/server.go index 46a277b3829..6e6be436ab4 100644 --- a/services/idp/pkg/command/server.go +++ b/services/idp/pkg/command/server.go @@ -91,9 +91,10 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). Str("transport", "http"). + Err(err). Msg("Shutting down server") cancel() diff --git a/services/nats/pkg/command/server.go b/services/nats/pkg/command/server.go index 5bed4387e9b..08ef0b44265 100644 --- a/services/nats/pkg/command/server.go +++ b/services/nats/pkg/command/server.go @@ -62,8 +62,9 @@ func Server(cfg *config.Config) *cli.Command { return <-err } - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Msg("Shutting down server") natsServer.Shutdown() diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index 7af4075539e..614a22b6c87 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -80,7 +80,10 @@ func Server(cfg *config.Config) *cli.Command { return s.Run() }, func(err error) { - logger.Info().Err(err).Str("server", c.Command.Name).Msg("Shutting down server") + logger.Error(). + Err(err). + Str("server", c.Command.Name). + Msg("Shutting down server") cancel() }) diff --git a/services/ocs/pkg/command/server.go b/services/ocs/pkg/command/server.go index 8de4dd160da..669fea4f6eb 100644 --- a/services/ocs/pkg/command/server.go +++ b/services/ocs/pkg/command/server.go @@ -63,7 +63,7 @@ func Server(cfg *config.Config) *cli.Command { ) if err != nil { - logger.Info(). + logger.Error(). Err(err). Str("transport", "http"). Msg("Failed to initialize server") @@ -73,8 +73,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("transport", "http"). Msg("Shutting down server") diff --git a/services/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index b41633ea951..88a6ed76ffc 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -97,8 +97,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", "http"). Msg("Shutting down server") diff --git a/services/search/pkg/command/server.go b/services/search/pkg/command/server.go index ab6284edf26..967fd96bf2f 100644 --- a/services/search/pkg/command/server.go +++ b/services/search/pkg/command/server.go @@ -59,7 +59,10 @@ func Server(cfg *config.Config) *cli.Command { ) gr.Add(grpcServer.Run, func(_ error) { - logger.Info().Str("server", "grpc").Msg("shutting down server") + logger.Error(). + Err(err). + Str("server", "grpc"). + Msg("shutting down server") cancel() }) diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index 97737f8afea..a08cd092669 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -66,8 +66,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index 66dd9c9d8ee..ece1c444d07 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -53,8 +53,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index e541979971c..243baa43d74 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -53,8 +53,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index b06a3ad908b..1e5aecd39f4 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -53,8 +53,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index 7cf8b60a998..1b93469990b 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -53,8 +53,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/store/pkg/command/server.go b/services/store/pkg/command/server.go index 8b08d7a4ebc..ceb0d0c84ef 100644 --- a/services/store/pkg/command/server.go +++ b/services/store/pkg/command/server.go @@ -62,8 +62,9 @@ func Server(cfg *config.Config) *cli.Command { grpc.Metrics(metrics), ) - gr.Add(server.Run, func(_ error) { - logger.Info(). + gr.Add(server.Run, func(err error) { + logger.Error(). + Err(err). Str("server", "grpc"). Msg("Shutting down server") diff --git a/services/thumbnails/pkg/command/server.go b/services/thumbnails/pkg/command/server.go index 7f8392c7f84..a6cfd16e68c 100644 --- a/services/thumbnails/pkg/command/server.go +++ b/services/thumbnails/pkg/command/server.go @@ -65,7 +65,11 @@ func Server(cfg *config.Config) *cli.Command { ) gr.Add(service.Run, func(_ error) { - fmt.Println("shutting down grpc server") + logger.Error(). + Err(err). + Str("server", "grpc"). + Msg("Shutting down server") + cancel() }) diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index 0073a8a6377..81d849d879e 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -66,8 +66,9 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) return nil - }, func(_ error) { - logger.Info(). + }, func(err error) { + logger.Error(). + Err(err). Str("server", cfg.Service.Name). Msg("Shutting down server") diff --git a/services/web/pkg/command/server.go b/services/web/pkg/command/server.go index ba7f1f539cb..2a90ff4e8ae 100644 --- a/services/web/pkg/command/server.go +++ b/services/web/pkg/command/server.go @@ -92,7 +92,7 @@ func Server(cfg *config.Config) *cli.Command { Msg("Failed to start server") } return err - }, func(_ error) { + }, func(err error) { logger.Info(). Str("transport", "http"). Msg("Shutting down server") diff --git a/services/webdav/pkg/command/server.go b/services/webdav/pkg/command/server.go index 9b59d7d3247..43f1744e0d8 100644 --- a/services/webdav/pkg/command/server.go +++ b/services/webdav/pkg/command/server.go @@ -73,8 +73,8 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error().Err(err).Msg("error ") - logger.Info(). + logger.Error(). + Err(err). Str("transport", "http"). Msg("Shutting down server")