diff --git a/cmd/root.go b/cmd/root.go index f5e25d3..4fafb67 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -136,6 +136,7 @@ func init() { rootCmd.Flags().StringVar(&config.SMTPSSLCert, "smtp-ssl-cert", config.SMTPSSLCert, "SSL certificate for SMTP - requires smtp-ssl-key") rootCmd.Flags().StringVar(&config.SMTPSSLKey, "smtp-ssl-key", config.SMTPSSLKey, "SSL key for SMTP - requires smtp-ssl-cert") + rootCmd.Flags().BoolVarP(&config.QuietLogging, "quiet", "q", false, "Quiet logging (errors only)") rootCmd.Flags().BoolVarP(&config.VerboseLogging, "verbose", "v", false, "Verbose logging") // deprecated 2022/08/06 diff --git a/config/config.go b/config/config.go index 0fb67db..ed199d3 100644 --- a/config/config.go +++ b/config/config.go @@ -26,6 +26,9 @@ var ( // VerboseLogging for console output VerboseLogging = false + // QuietLogging for console output (errors only) + QuietLogging = false + // NoLogging for tests NoLogging = false diff --git a/logger/logger.go b/logger/logger.go index aa0e30f..63ca810 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -19,9 +19,13 @@ func Log() *logrus.Logger { log = logrus.New() log.SetLevel(logrus.InfoLevel) if config.VerboseLogging { + // verbose logging (debug) log.SetLevel(logrus.DebugLevel) - } - if config.NoLogging { + } else if config.QuietLogging { + // show errors only + log.SetLevel(logrus.ErrorLevel) + } else if config.NoLogging { + // disable all logging (tests) log.SetLevel(logrus.PanicLevel) }