3

Hi I am running my unit tests by using: godep go test -v -run TestMyCode,

but I did not find a way to show my info logs in my tests:

glog.V(4).Infof("Adding new pods from source %s : %v", source, update.Pods)

Is it possible?

harryz
  • 4,980
  • 6
  • 31
  • 34

1 Answers1

4

You can log your messages to console by setting few flags. Try the below code in the init() function.

flag.Set("alsologtostderr", fmt.Sprintf("%t", true))
var logLevel string
flag.StringVar(&logLevel, "logLevel", "4", "test")
flag.Lookup("v").Value.Set(logLevel)
IhtkaS
  • 1,314
  • 3
  • 15
  • 31