Provide a test mode to check plugins easily

This commit is contained in:
Evan Phoenix
2015-04-06 17:24:24 -07:00
parent 7b0c09d5e9
commit 609cba2cd5
3 changed files with 62 additions and 5 deletions

View File

@@ -1,12 +1,32 @@
package tivan
import "github.com/influxdb/influxdb/client"
import (
"fmt"
"sort"
"strings"
"github.com/influxdb/influxdb/client"
)
type BatchPoints struct {
client.BatchPoints
Debug bool
}
func (bp *BatchPoints) Add(name string, val interface{}, tags map[string]string) {
if bp.Debug {
var tg []string
for k, v := range tags {
tg = append(tg, fmt.Sprintf("%s=\"%s\"", k, v))
}
sort.Strings(tg)
fmt.Printf("> [%s] %s=%v\n", strings.Join(tg, " "), name, val)
}
bp.Points = append(bp.Points, client.Point{
Name: name,
Tags: tags,