Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/out_gstdout/out_gstdout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion examples/out_multiinstance/out.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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
}

Expand Down