git » chasquid » commit 2b46f30

trace: Include debug messages in the traces

author Alberto Bertogli
2016-10-08 13:39:27 UTC
committer Alberto Bertogli
2016-10-09 23:51:05 UTC
parent 3e55b0d74230245b9835a3baac8748b1438f2ae0

trace: Include debug messages in the traces

We don't want to write debug messages to the log, but having them in
traces is always useful.

The traces are volatile and self-cleaning so the additional volume
should not cause any problems, and helps troubleshooting.

While at it, fix the depth constant when logging.

internal/trace/trace.go +4 -3

diff --git a/internal/trace/trace.go b/internal/trace/trace.go
index fa4130f..d96d9c5 100644
--- a/internal/trace/trace.go
+++ b/internal/trace/trace.go
@@ -25,16 +25,17 @@ func (t *Trace) Printf(format string, a ...interface{}) {
 	if glog.V(0) {
 		msg := fmt.Sprintf("%s %s: %s", t.family, t.title,
 			quote(fmt.Sprintf(format, a...)))
-		glog.InfoDepth(2, msg)
+		glog.InfoDepth(1, msg)
 	}
 }
 
 func (t *Trace) Debugf(format string, a ...interface{}) {
+	t.t.LazyPrintf(format, a...)
+
 	if glog.V(2) {
-		t.t.LazyPrintf(format, a...)
 		msg := fmt.Sprintf("%s %s: %s", t.family, t.title,
 			quote(fmt.Sprintf(format, a...)))
-		glog.InfoDepth(2, msg)
+		glog.InfoDepth(1, msg)
 	}
 }