Commit 7c3f032c authored by Xiaowu Zhang's avatar Xiaowu Zhang

check output

parent cbad0852
...@@ -50,6 +50,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int ...@@ -50,6 +50,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
// Iterate Records // Iterate Records
var result string var result string
result = "" result = ""
var is_end bool = false
for { for {
// Extract Record // Extract Record
ret, ts, record = output.GetRecord(dec) ret, ts, record = output.GetRecord(dec)
...@@ -72,10 +73,14 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int ...@@ -72,10 +73,14 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
result = result + C.GoString(tag) + ":" +timestamp.String() result = result + C.GoString(tag) + ":" +timestamp.String()
for _, v := range record { for _, v := range record {
result += "[" result += "["
var output_string string = ""
for _, s := range v.([]uint8) { for _, s := range v.([]uint8) {
result = result + string(s) output_string = output_string + string(s)
} }
result += "]" if output_string == "fluentbit_end" {
is_end = true
}
result = result + output_string + "]"
} }
result += "\n" result += "\n"
} }
...@@ -88,7 +93,6 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int ...@@ -88,7 +93,6 @@ 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{
...@@ -111,7 +115,9 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int ...@@ -111,7 +115,9 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
fmt.Printf("status code %d", rsp.StatusCode) fmt.Printf("status code %d", rsp.StatusCode)
return output.FLB_RETRY return output.FLB_RETRY
} }
os.Exit(0) if is_end {
os.Exit(0)
}
return output.FLB_OK return output.FLB_OK
} }
......
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