diff --git a/cmd/versitygw/main.go b/cmd/versitygw/main.go index b9828c52..42b4f720 100644 --- a/cmd/versitygw/main.go +++ b/cmd/versitygw/main.go @@ -43,6 +43,7 @@ var ( logWebhookURL string accessLog string debug bool + quiet bool iamDir string ldapURL, ldapBindDN, ldapPassword string ldapQueryBase, ldapObjClasses string @@ -176,6 +177,12 @@ func initFlags() []cli.Flag { Usage: "enable debug output", Destination: &debug, }, + &cli.BoolFlag{ + Name: "quiet", + Usage: "silence stdout request logging output", + Destination: &quiet, + Aliases: []string{"q"}, + }, &cli.StringFlag{ Name: "access-log", Usage: "enable server access logging to specified file", @@ -348,6 +355,9 @@ func runGateway(ctx context.Context, be backend.Backend) error { if admPort == "" { opts = append(opts, s3api.WithAdminServer()) } + if quiet { + opts = append(opts, s3api.WithQuiet()) + } admApp := fiber.New(fiber.Config{ AppName: "versitygw", diff --git a/s3api/server.go b/s3api/server.go index 0cbee9b7..8fe61c7c 100644 --- a/s3api/server.go +++ b/s3api/server.go @@ -32,6 +32,7 @@ type S3ApiServer struct { router *S3ApiRouter port string cert *tls.Certificate + quiet bool debug bool } @@ -48,7 +49,9 @@ func New(app *fiber.App, be backend.Backend, root middlewares.RootUserConfig, po } // Logging middlewares - app.Use(logger.New()) + if !server.quiet { + app.Use(logger.New()) + } app.Use(middlewares.DecodeURL(l)) app.Use(middlewares.RequestLogger(server.debug)) @@ -80,6 +83,11 @@ func WithDebug() Option { return func(s *S3ApiServer) { s.debug = true } } +// WithQuiet silences default logging output +func WithQuiet() Option { + return func(s *S3ApiServer) { s.quiet = true } +} + func (sa *S3ApiServer) Serve() (err error) { if sa.cert != nil { return sa.app.ListenTLSWithCertificate(sa.port, *sa.cert)