diff --git a/examples/out_gstdout/out_gstdout.go b/examples/out_gstdout/out_gstdout.go index 8a0acd9..2a815ec 100644 --- a/examples/out_gstdout/out_gstdout.go +++ b/examples/out_gstdout/out_gstdout.go @@ -14,9 +14,10 @@ func FLBPluginRegister(def unsafe.Pointer) int { return output.FLBPluginRegister(def, "gstdout", "Stdout GO!") } -//export FLBPluginInit // (fluentbit will call this) // plugin (context) pointer to fluentbit context (state/ c code) +// +//export FLBPluginInit func FLBPluginInit(plugin unsafe.Pointer) int { // Example to retrieve an optional configuration parameter param := output.FLBPluginConfigKey(plugin, "param") @@ -46,7 +47,7 @@ func FLBPluginFlush(data unsafe.Pointer, length C.int, tag *C.char) int { var timestamp time.Time switch t := ts.(type) { case output.FLBTime: - timestamp = ts.(output.FLBTime).Time + timestamp = t.Time case uint64: timestamp = time.Unix(int64(t), 0) default: diff --git a/examples/out_multiinstance/out.go b/examples/out_multiinstance/out.go index d6290f5..117cf66 100644 --- a/examples/out_multiinstance/out.go +++ b/examples/out_multiinstance/out.go @@ -50,10 +50,12 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int var timestamp time.Time switch t := ts.(type) { case output.FLBTime: - timestamp = ts.(output.FLBTime).Time + timestamp = t.Time case uint64: timestamp = time.Unix(int64(t), 0) default: + // the fluent-bit V2 timestamp layout: []interface{output.FLBTime, map} . + // if use old fluent-bit-go version, it cause invalid format error. fmt.Println("time provided invalid, defaulting to now.") timestamp = time.Now() } @@ -68,6 +70,11 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int count++ } + // Return options: + // + // output.FLB_OK = data have been processed. + // output.FLB_ERROR = unrecoverable error, do not try this again. + // output.FLB_RETRY = retry to flush later. return output.FLB_OK }