From 5766eb87951ba5295736e3458f81e1eab30fc7d2 Mon Sep 17 00:00:00 2001 From: "A. Diamond" Date: Thu, 28 Mar 2024 16:09:31 -0400 Subject: [PATCH] Stop DART from printing debug into to terminal in release mode. --- dart/main.go | 2 +- server/release_loader.go | 3 +-- server/server.go | 11 ++++++----- util/util.go | 2 -- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/dart/main.go b/dart/main.go index 733e753..d8ba0ff 100644 --- a/dart/main.go +++ b/dart/main.go @@ -13,5 +13,5 @@ func main() { port := flag.Int("port", 8080, "Which port should DART listen on?") flag.Parse() server.SetVersion(Version) - server.Run(*port) + server.Run(*port, true) } diff --git a/server/release_loader.go b/server/release_loader.go index a7c4f0a..a2ba520 100644 --- a/server/release_loader.go +++ b/server/release_loader.go @@ -4,7 +4,6 @@ package server import ( "embed" - "fmt" "html/template" "io/fs" "net/http" @@ -95,7 +94,7 @@ func loadAndAddToRoot(funcMap template.FuncMap, rootTemplate *template.Template, if _, parseErr := t.Parse(string(data)); parseErr != nil { return parseErr } - fmt.Println(" template", path) + //fmt.Println(" template", path) } return nil }) diff --git a/server/server.go b/server/server.go index 2bcc3da..84331fe 100644 --- a/server/server.go +++ b/server/server.go @@ -13,12 +13,12 @@ import ( // Run runs the Registry application. This is called from main() to start // the app. Listen on 127.0.0.1, not on 0.0.0.0 because we don't want to // accept outside connections. -func Run(port int) { +func Run(port int, quietMode bool) { if port < 1 { port = 8080 } core.Dart.RuntimeMode = constants.ModeDartGUI - r := InitAppEngine(false) + r := InitAppEngine(quietMode) r.Run(fmt.Sprintf("127.0.0.1:%d", port)) } @@ -33,12 +33,13 @@ func SetVersion(version string) { // middleware and defining routes. The test suite can use this to get an // instance of the Gin engine to bind to. // -// Set param discardStdOut during unit/integration tests to suppress +// Set param quietMode during unit/integration tests to suppress // Gin's STDOUT logging. Those log statements are useful in development, // but can be verbose and clutter the test output. -func InitAppEngine(discardStdOut bool) *gin.Engine { +func InitAppEngine(quietMode bool) *gin.Engine { var r *gin.Engine - if discardStdOut { + if quietMode { + gin.SetMode(gin.ReleaseMode) r = gin.New() r.Use(gin.Recovery()) gin.DefaultWriter = io.Discard diff --git a/util/util.go b/util/util.go index 73036f4..a82210c 100644 --- a/util/util.go +++ b/util/util.go @@ -286,12 +286,10 @@ func PathToUnitTestBag(bagName string) string { // TestsAreRunning returns true when code is running under "go test" func TestsAreRunning() bool { - //return flag.Lookup("test.v") != nil || strings.HasSuffix(os.Args[0], ".test") || (len(os.Args) > 1 && os.Args[1] == "-test.run") if strings.HasSuffix(os.Args[0], ".test") || os.Getenv("DART_ENV") == "test" { return true } for _, arg := range os.Args { - fmt.Println(arg) if strings.HasPrefix(arg, "-test.") { return true }