--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
That's an error. It is supposed to be Apache 2.0. We will fix it.
By binding methods to booleans it is possible to use the log packagewithout paying the expense of evaluating the arguments to the log.
Hi,
what its meant by:
On Tuesday, July 16, 2013 7:44:10 AM UTC+2, Rob Pike wrote:By binding methods to booleans it is possible to use the log packagewithout paying the expense of evaluating the arguments to the log.
You can call Info() directly on the returned level which is said boolean referred to earlier like so:
V(2).Info()
--
You can call Info() directly on the returned level which is said boolean referred to earlier like so:
V(2).Info()
No i think that is the point of Robs comment about binding functions to a boolean. Check the source it actually contains an if that does it for you.
Hmm ill have to take another look i could have sworn i saw something along those lines. Would be nice to be able to do away with the explicit checks tho.
http://play.golang.org/p/q0E1btmyHsAre you sure? It seems to return a false level in case the wanted level is greater and it is guarded by itself in the Info call.Am I missing something fundamental?
--
flag.Parse() // required.package mainimport ("flag")func main() {
// But this works:
Some glog mysteries solved. Some not. I redid the 'go get' just now.Ubuntu Linux 13.04 x86_64. go version go1.1.1 linux/amd64
- You have to: import "flag" as well as ".../glog"
- call flag.Parse() in main().
- call glog.Flush() at the end. Or periodically. Or the output does not appear.
- I cannot give you an example on the playground. No glog there.
- I was surprised to see so many different files and symlinks output. Still thinking about this.
But:
- This compiles and runs:
glog.V(glog.Level(i)).Infof(" Infof: Hell. Oh. Urled. %d\n", i)
- Whereas this gets a syntax error:
glog.V(glog.Level(i)).Errorf("Errorf: Hell. Oh. Urled. %d\n", i)
glog.V(glog.Level(i)).Errorf undefined (type glog.Verbose has no field or method Errorf)- This seems very inconsistent. Is there a rationale? Is broke or am I missing something?
- When you use a ./log directory, the symlinks are still broken, as reported by somebody else, first.
———————————————————————————Here is the complete program:I run it with: go run noodleGlog.go -v=2 -log_dir=logflag.Parse() // required.package main
import ("flag")func main() {
glog.Info("Do you see this message?\n") // Yes.
for i := 0; i < 5; i++ {
glog.V(glog.Level(i)).Infof(" Infof: Hell. Oh. Urled. %d\n", i)
//glog.V(glog.Level(i)).Errorf("Errorf: Hell. Oh. Urled. %d\n", i)// Mysterious Syntax Error .// But this works:
glog.Errorf("Errorf: Hell. Oh. Urled. %d\n", i)
}
glog.Flush() // required.
}Please forgive "hell oh urled". It's "hello world" in the web dialect.
———————————————————————————
On Tuesday, July 16, 2013 8:44:10 AM UTC+3, Rob Pike wrote:...
--
On 16 July 2013 18:20, Henrik Johansson <dahan...@gmail.com> wrote:
> I do however have some problems. Running like this:
>
> ./myprog -v=2
>
> logs nothing with either glog.V(2).Info("message")
> or glog.Info("message")
Pass -logtostderr to the program too. Or -log_dir=/some/path.
> Also perhaps I am missunderstanding how logging to the system log works but
> should that not also consider the levels? It seems to always log with
> -alsologtostderr=true regardless of level.
If it's going to alsologtostderr, all levels are logged there. The
character at the start of the line tells you what level it is.