Browse files

Add debug.

  • Loading branch information...
1 parent f03ac8c commit c15f87a3d22ef0a2c470ea41f228bec2d91884c9 @jbuchbinder committed May 30, 2012
Showing with 13 additions and 1 deletion.
  1. +12 −0 gmetric/gmetric.go
  2. +1 −1 test/main.go
View
12 gmetric/gmetric.go
@@ -1,6 +1,7 @@
package gmetric
import (
+ "log"
"net"
)
@@ -99,6 +100,8 @@ func (g *Gmetric) BuildMetadataPacket(host string, name string, metricType uint3
}
}
+ g.DebugBuffer(buf, buf_len)
+
return buf, buf_len
}
@@ -123,6 +126,8 @@ func (g *Gmetric) BuildValuePacket(host string, name string, metricType uint32,
g.AppendXDRString(buf, buf_len, "%s")
g.AppendXDRString(buf, buf_len, value)
+ g.DebugBuffer(buf, buf_len)
+
return buf, buf_len
}
@@ -179,3 +184,10 @@ func (g *Gmetric) TypeToString(t uint32) string {
}
return "unknown"
}
+
+func (g *Gmetric) DebugBuffer(buf []byte, buf_len uint32) {
+ log.Printf("Buffer contains %d bytes\n", buf_len)
+ for i := 0; i < int(buf_len); i++ {
+ log.Printf("Position %d contains byte value %d\n", i, buf[i])
+ }
+}
View
2 test/main.go
@@ -14,6 +14,6 @@ func main() {
for i := 0; i < 10; i++ {
log.Printf("Sending packet for some_metric_%d", i)
- gm.SendMetric(fmt.Sprintf("some_metric_%d", i), "8675309", gmetric.VALUE_UNSIGNED_INT, "units", gmetric.SLOPE_BOTH, 300, 600, "GROUP")
+ go gm.SendMetric(fmt.Sprintf("some_metric_%d", i), "8675309", gmetric.VALUE_UNSIGNED_INT, "units", gmetric.SLOPE_BOTH, 300, 600, "GROUP")
}
}

0 comments on commit c15f87a

Please sign in to comment.