Skip to content

Instantly share code, notes, and snippets.

@atotto

atotto/foo.go

Last active Dec 20, 2015
Embed
What would you like to do?
package main
import (
"github.com/golang/glog"
)
func foo() {
glog.Info("info v1")
glog.Error("error v1")
glog.V(2).Info("info v2")
}
package main
import (
"flag"
"github.com/golang/glog"
)
func main() {
flag.Parse()
glog.Info("info v1")
glog.Error("error v1")
if glog.V(2) {
glog.Info("info v2")
glog.Error("error v2")
}
glog.V(3).Info("info v3")
if glog.V(3) {
glog.Error("error v3")
}
foo()
}

--help

$ ./glog --help
Usage of ./glog:
  -alsologtostderr=false: log to standard error as well as files
  -log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
  -log_dir="": If non-empty, write log files in this directory
  -logtostderr=false: log to standard error instead of files
  -stderrthreshold=0: logs at or above this threshold go to stderr
  -v=0: log level for V logs
  -vmodule=: comma-separated list of pattern=N settings for file-filtered logging

-logtostderr

$ ./glog -logtostderr
I0720 11:05:38.503918 25749 main.go:12] info v1
E0720 11:05:38.504035 25749 main.go:13] error v1
I0720 11:05:38.504043 25749 foo.go:8] info v1
E0720 11:05:38.504049 25749 foo.go:9] error v1

-vmodule=foo=2

$ ./glog -logtostderr -vmodule=foo=2
I0720 11:07:04.466255 25795 main.go:12] info v1
E0720 11:07:04.466354 25795 main.go:13] error v1
I0720 11:07:04.466366 25795 foo.go:8] info v1
E0720 11:07:04.466372 25795 foo.go:9] error v1
I0720 11:07:04.466378 25795 foo.go:11] info v2

-log_dir="."

$ ./glog -log_dir="."
E0720 13:41:21.245751 26875 main.go:12] error v1
E0720 13:41:21.246226 26875 foo.go:9] error v1
$ ls
glog
glog.Mac.atotto.log.ERROR.20130720-134121.26875
glog.Mac.atotto.log.INFO.20130720-134121.26875
glog.Mac.atotto.log.WARNING.20130720-134121.26875
glog.ERROR
glog.INFO
glog.WARNING
foo.go
main.go
@atotto

This comment has been minimized.

Copy link
Owner Author

@atotto atotto commented Jul 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment