Skip to content

Commit

Permalink
Stop DART from printing debug into to terminal in release mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondap committed Mar 28, 2024
1 parent 0cf2344 commit 5766eb8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dart/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
3 changes: 1 addition & 2 deletions server/release_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package server

import (
"embed"
"fmt"
"html/template"
"io/fs"
"net/http"
Expand Down Expand Up @@ -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
})
Expand Down
11 changes: 6 additions & 5 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5766eb8

Please sign in to comment.