Boolean alias
glog.V is neat-o
March 16, 2018glog implements log levels with a nice boolean alias. Starting at line #983, the Verbose
, when wrapping the boolean true
causes its various functions to invoke the logger. So if you pass in -v 3
on the command line and use glog.V(2).Info("hello")
in code, your logger will write the message. This allows glog to have far fewer log levels than most loggers. It's still a log more complicated than the build in log
, which is a minimal stdout
/stderr
logger.
My levels are -v 1
to see high-level success, -v 2
to trace activity, and -v 3
to dump object values. I also log user-level and processing failures as Warning
, and critical missing functionality as Error
. I haven't found many uses for Fatal
or Exit
logs, yet.