DescriptionDo not forget to call `defer glog.Flush()`in our applications.
I did a little experiment to verify if this call was or not necessary.
The experiment was:
$ go get github.com/golang/glog
Without Flush() call:
$ cat example1.go
package main
import "flag"
import "github.com/golang/glog"
func main() {
flag.Parse()
glog.Infoln("Prepare to repel boarders")
}
$ mkdir log
$ go run example1.go -log_dir=./log
Then take a look at the log files under ./log dir. You won't see the message "Prepare to repel boarders" there.
With Flush() call:
$ cat example2.go
package main
import "flag"
import "github.com/golang/glog"
func main() {
flag.Parse()
defer glog.Flush()
glog.Infoln("Prepare to repel boarders")
}
$ mkdir log2
$ go run example2.go -log_dir=./log2
Now look at the log files under ./log2 dir, you should see the "Prepare to repel boarders" message there.
So in order to properly store the log messages of your server applications we need to add the call `defer glog.Flush()` to them.
Also the documentation in https://godoc.org/github.com/golang/glog state that pretty clear with the following phrase: "Programs should call Flush before exiting to guarantee all log output is written."
The above experiment/finding is also available and documented at https://github.com/tfarina/rsc/tree/master/go/golang_glog.
BUG=None
TEST=see above
R=jcgregorio@google.com
Committed: https://skia.googlesource.com/buildbot/+/a8a82069d68618942fdf7b7f8ce31f95ef7548ee
Patch Set 1 #Patch Set 2 : cleanup golden/go/skiacorrectness/main.go comments #Patch Set 3 : revert titletool changes #
Messages
Total messages: 5 (1 generated)
|