Hi,
########################################################################################################################
Error:-
########################################################################################################################
$./tst --help
usage: example -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]
-alsologtostderr
log to standard error as well as files
-log_backtrace_at value
when logging hits line file:N, emit a stack trace
-log_dir string
If non-empty, write log files in this directory
-log_link string
If non-empty, add symbolic links in this directory to the log files
-logbuflevel int
Buffer log messages logged at this level or lower (-1 means don't buffer; 0 means buffer INFO only; ...). Has limited applicability on non-prod platforms.
-logtostderr
log to standard error instead of files
-stderrthreshold value
logs at or above this threshold go to stderr (default 2)
-v value
log level for V logs
-vmodule value
comma-separated list of pattern=N settings for file-filtered logging
panic calling String method on zero glog.vModuleFlag for flag vmodule: runtime error: invalid memory address or nil pointer dereference
########################################################################################################################
Example code:-
########################################################################################################################
package main
import (
"os"
"flag"
"fmt"
)
func usage() {
fmt.Fprintf(os.Stderr, "usage: example -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]\n", )
flag.PrintDefaults()
os.Exit(2)
}
func init() {
flag.Usage = usage
// NOTE: This next line is key you have to call flag.Parse() for the command line
// options or "flags" that are defined in the glog module to be picked up.
flag.Parse()
}
func main() {
number_of_lines := 100000
for i := 0; i < number_of_lines; i++ {
glog.V(2).Infof("LINE: %d", i)
message := fmt.Sprintf("TEST LINE: %d", i)
glog.Error(message)
}
glog.Flush()
}
########################################################################################################################