11407: keepclient checks for ARVADOS_DEBUG and enables debugging.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 3 Apr 2017 19:26:50 +0000 (15:26 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 3 Apr 2017 20:20:58 +0000 (16:20 -0400)
sdk/go/keepclient/support.go

index 22447794f1c7f93c4eca6fcdec83d254cbc1740b..9adbb4878f40541eb13c0feed39bf22241f4c3f5 100644 (file)
@@ -7,9 +7,12 @@ import (
        "git.curoverse.com/arvados.git/sdk/go/streamer"
        "io"
        "io/ioutil"
+       "log"
        "math/rand"
        "net"
        "net/http"
+       "os"
+       "regexp"
        "strings"
        "time"
 )
@@ -19,6 +22,13 @@ import (
 // log.Printf to DebugPrintf.
 var DebugPrintf = func(string, ...interface{}) {}
 
+func init() {
+       var matchTrue = regexp.MustCompile("^(?i:1|yes|true)$")
+       if matchTrue.MatchString(os.Getenv("ARVADOS_DEBUG")) {
+               DebugPrintf = log.Printf
+       }
+}
+
 type keepService struct {
        Uuid     string `json:"uuid"`
        Hostname string `json:"service_host"`