Do 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

Review URL: https://codereview.chromium.org/659943006