diff --git a/cmd/root.go b/cmd/root.go index c92b209..2e917ed 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -98,8 +98,8 @@ func init() { rootCmd.Flags().BoolVar(&config.SMTPAuthAllowInsecure, "smtp-auth-allow-insecure", config.SMTPAuthAllowInsecure, "Enable insecure PLAIN & LOGIN authentication") rootCmd.Flags().StringVarP(&config.SMTPCLITags, "tag", "t", config.SMTPCLITags, "Tag new messages matching filters") - rootCmd.Flags().BoolVarP(&config.QuietLogging, "quiet", "q", config.QuietLogging, "Quiet logging (errors only)") - rootCmd.Flags().BoolVarP(&config.VerboseLogging, "verbose", "v", config.VerboseLogging, "Verbose logging") + rootCmd.Flags().BoolVarP(&logger.QuietLogging, "quiet", "q", logger.QuietLogging, "Quiet logging (errors only)") + rootCmd.Flags().BoolVarP(&logger.VerboseLogging, "verbose", "v", logger.VerboseLogging, "Verbose logging") // deprecated flags 2022/08/06 rootCmd.Flags().StringVarP(&config.UIAuthFile, "auth-file", "a", config.UIAuthFile, "A password file for web UI authentication") diff --git a/config/config.go b/config/config.go index dbfae59..3501aca 100644 --- a/config/config.go +++ b/config/config.go @@ -30,15 +30,6 @@ var ( // UseMessageDates sets the Created date using the message date, not the delivered date UseMessageDates bool - // VerboseLogging for console output - VerboseLogging = false - - // QuietLogging for console output (errors only) - QuietLogging = false - - // NoLogging for tests - NoLogging = false - // UITLSCert file UITLSCert string diff --git a/server/server_test.go b/server/server_test.go index 2bee1ec..a489efd 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -14,6 +14,7 @@ import ( "github.com/axllent/mailpit/config" "github.com/axllent/mailpit/server/apiv1" "github.com/axllent/mailpit/storage" + "github.com/axllent/mailpit/utils/logger" "github.com/jhillyerd/enmime" ) @@ -150,7 +151,7 @@ func Test_APIv1(t *testing.T) { } func setup() { - config.NoLogging = true + logger.NoLogging = true config.MaxMessages = 0 config.DataFile = "" diff --git a/storage/database_test.go b/storage/database_test.go index 07fd35f..344bdc1 100644 --- a/storage/database_test.go +++ b/storage/database_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/axllent/mailpit/config" + "github.com/axllent/mailpit/utils/logger" "github.com/jhillyerd/enmime" ) @@ -230,7 +231,7 @@ func BenchmarkImportMime(b *testing.B) { } func setup() { - config.NoLogging = true + logger.NoLogging = true config.MaxMessages = 0 config.DataFile = "" diff --git a/utils/logger/logger.go b/utils/logger/logger.go index 7496bdd..9214eb3 100644 --- a/utils/logger/logger.go +++ b/utils/logger/logger.go @@ -7,12 +7,17 @@ import ( "os" "regexp" - "github.com/axllent/mailpit/config" "github.com/sirupsen/logrus" ) var ( log *logrus.Logger + // VerboseLogging for verbose logging + VerboseLogging bool + // QuietLogging shows only errors + QuietLogging bool + // NoLogging shows only fatal errors + NoLogging bool ) // Log returns the logger instance @@ -20,13 +25,13 @@ func Log() *logrus.Logger { if log == nil { log = logrus.New() log.SetLevel(logrus.InfoLevel) - if config.VerboseLogging { + if VerboseLogging { // verbose logging (debug) log.SetLevel(logrus.DebugLevel) - } else if config.QuietLogging { + } else if QuietLogging { // show errors only log.SetLevel(logrus.ErrorLevel) - } else if config.NoLogging { + } else if NoLogging { // disable all logging (tests) log.SetLevel(logrus.PanicLevel) }