Commit cbad0852 authored by Xiaowu Zhang's avatar Xiaowu Zhang

readable output

parent d53dba5a
...@@ -41,16 +41,13 @@ func FLBPluginInit(plugin unsafe.Pointer) int { ...@@ -41,16 +41,13 @@ func FLBPluginInit(plugin unsafe.Pointer) int {
//export FLBPluginFlushCtx //export FLBPluginFlushCtx
func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int { func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int {
var count int
var ret int var ret int
var ts interface{} var ts interface{}
var record map[interface{}]interface{} var record map[interface{}]interface{}
// Create Fluent Bit decoder // Create Fluent Bit decoder
dec := output.NewDecoder(data, int(length)) dec := output.NewDecoder(data, int(length))
dict := output.FLBPluginGetContext(ctx).(map[string]string) dict := output.FLBPluginGetContext(ctx).(map[string]string)
fmt.Printf("streamtool_uri %s \n", dict["streamtool_uri"])
// Iterate Records // Iterate Records
count = 0
var result string var result string
result = "" result = ""
for { for {
...@@ -72,12 +69,15 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int ...@@ -72,12 +69,15 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
} }
// Print record keys and values // Print record keys and values
result = result + C.GoString(tag) + ":[" +timestamp.String() result = result + C.GoString(tag) + ":" +timestamp.String()
for k, v := range record { for _, v := range record {
result = result + fmt.Sprintf("%s: %v", k,v) result += "["
for _, s := range v.([]uint8) {
result = result + string(s)
} }
result += "}\n" result += "]"
count++ }
result += "\n"
} }
// Return options: // Return options:
...@@ -88,6 +88,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int ...@@ -88,6 +88,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
//body result //body result
// content type "application/octet-stream" // content type "application/octet-stream"
// //
fmt.Println(result)
var b = []byte(result) var b = []byte(result)
uri := fmt.Sprintf("%s/ingest?reference=#%s", dict["streamtool_uri"], C.GoString(tag)) uri := fmt.Sprintf("%s/ingest?reference=#%s", dict["streamtool_uri"], C.GoString(tag))
client := &http.Client{ 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