Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit fccea50

Browse files
committed
Add verbose flag, hide Goose logs by default
The Goose status logs are quite noisy, especially in unit tests. This adds a -v flag for only printing those messages when desired, making test output quiet.
1 parent d44caf4 commit fccea50

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scan.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var (
4242
credsFile string
4343
dataDir string
4444
httpsAddr string
45+
verbose bool
4546

4647
// HTML templates
4748
tmpl *template.Template
@@ -72,8 +73,14 @@ func openDB(dsn string) error {
7273
log.Fatal(err)
7374
}
7475
defer os.RemoveAll(tmpdir)
75-
log.Println("Checking database migration status")
76-
goose.Status(db, tmpdir)
76+
77+
if verbose {
78+
log.Println("Checking database migration status")
79+
goose.Status(db, tmpdir)
80+
} else {
81+
// Discard Goose's log output
82+
goose.SetLogger(log.New(ioutil.Discard, "", 0))
83+
}
7784
err = goose.Up(db, tmpdir)
7885
if err != nil {
7986
log.Fatalf("Error running database migrations: %v\n", err)
@@ -964,6 +971,7 @@ func main() {
964971
"This is useful when exposing metrics on a public interface")
965972
enableTLS := flag.Bool("tls", false, "Enable AutoTLS")
966973
tlsHostname := flag.String("tls.hostname", "", "(Optional) Restrict AutoTLS to `hostname`")
974+
flag.BoolVar(&verbose, "v", false, "Enable verbose logging")
967975
flag.Parse()
968976

969977
// Disable TLS on metrics if TLS wasn't generally enabled as autocert

0 commit comments

Comments
 (0)