Commit cbad0852 authored by Xiaowu Zhang's avatar Xiaowu Zhang

readable output

parent d53dba5a
......@@ -41,16 +41,13 @@ func FLBPluginInit(plugin unsafe.Pointer) int {
//export FLBPluginFlushCtx
func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int {
var count int
var ret int
var ts interface{}
var record map[interface{}]interface{}
// Create Fluent Bit decoder
dec := output.NewDecoder(data, int(length))
dict := output.FLBPluginGetContext(ctx).(map[string]string)
fmt.Printf("streamtool_uri %s \n", dict["streamtool_uri"])
// Iterate Records
count = 0
var result string
result = ""
for {
......@@ -72,12 +69,15 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
}
// Print record keys and values
result = result + C.GoString(tag) + ":[" +timestamp.String()
for k, v := range record {
result = result + fmt.Sprintf("%s: %v", k,v)
result = result + C.GoString(tag) + ":" +timestamp.String()
for _, v := range record {
result += "["
for _, s := range v.([]uint8) {
result = result + string(s)
}
result += "]"
}
result += "}\n"
count++
result += "\n"
}
// Return options:
......@@ -88,6 +88,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
//body result
// content type "application/octet-stream"
//
fmt.Println(result)
var b = []byte(result)
uri := fmt.Sprintf("%s/ingest?reference=#%s", dict["streamtool_uri"], C.GoString(tag))
client := &http.Client{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment